(1.)訪問元素&元件
大多數情況下,不要觸達另乙個元件例項內部或手動操作dom元素。不過有些情況下是可以的。
new
vue(
, computed:},
methods:}}
)this
.$root.foo // 子元件獲取根元件的資料
this
.$root.foo =
2// 寫入根元件的資料
this
.$root.bar // 訪問根元件的計算屬性
this
.$root.
baz(
)// 呼叫根元件的方法
對於demo或非常小型的少量元件的應用來說很方便,在大型專案裡推介vuex
來管理應用狀態。
<
!--google-map可以定義乙個map property,google-map-markers可以通過this
.$parent.getmap的方式來訪問--
>
"icecreamshops"
>
<
/google-map-markers>
<
/google-map>
<
!--當在google-map-markers外層再加一層新的元件,這時再去訪問則需要用this
.$parent.$parent.map來訪問--
>
"cityboundaries"
>
"icecreamshops"
>
<
/google-map-markers>
<
/google-map-region>
<
/google-map>
"usernameinput"
>
<
/base-input>
在已經定義這個ref
的元件的元件裡,可以使用:this.$refs.usernameinput
來訪問這個
例項。
甚至可以通過父級元件定義方法,例:
methods:
}
整個完整例項:
>
<
!--此處為子元件加ref--
>
"usernameinput"
>
<
/component-three>
"clickfocus"
>心情按鈕<
/button>
<
/div>
"componentc"
>
}<
/p>
<
/template>
vue.
component
('component-three',}
`,data:
function()
},methods:}}
)var vm =
newvue(}
})<
/script>
provide:
function()
}
inject:
['getmap'
]
(2.)程式化的事件偵聽器
$emit
可以被v-on
偵聽,vue例項同時在其事件介面中提供了其他方法。
(3.)迴圈引用
name:
'unique-name-of-my-component'
name:
'stack-overflow'
,template:
''
(4.)模板定義替代品
these are compiled as the component's own template.
<
/p>
not parent's transclusion content.
<
/p>
<
/div>
<
/my-component>
(5.)控制更新 mediawiki邊界處理
在使用wiki中發現,內容頁面始終佔據瀏覽器100 寬度,乙個不好的表現就是 當需要編輯特殊欄位時,編輯 始終在瀏覽器最右方,不方便操作,而且,文章內容佔據寬度過長,不易於瀏覽。因此,改動方法有二。其一,在編輯新頁面時,人為的寫入 內容 之後在 內容 替換為自己想要輸入的內容即可,n 替換為需要的百...
OpenCV邊界處理型別
1.邊界處理的型別 2.opencv的實現 在影象處理中,經常需要空域或頻域的濾波處理,在進入真正的處理程式前,需要考慮影象邊界情況。通常的處理方法是為影象增加一定的邊緣,以適應 卷積核 在原影象邊界的操作。1.增加邊界的型別有以下4個型別 以一行影象資料為例,abcdefgh是原圖資料,是影象邊界...
卷積邊界處理 copyMakeBorder
進行卷積處理影像時,在影像的邊界,核心沒有足夠元素納入計算,opencv裡用copymakeborder 函式將原圖稍微放大,再開始進行卷積,opencv在空間濾波的相關函式內部已包含copymakeborder 了,所以實際上使用空間濾波時,不需要呼叫copymakeborder 在opencv裡...