插值表達式加載閃爍問題:
<h1 v-cloak> {{msg}} </h1>
[v-cloka] {
display: none;
}
在使用 v-for時一定要綁定key, :key = string | integer. 這樣循環的數組改變時也不會出現複選框勾選不一致問題。
在vue中回調函數儘量使用es6 箭頭函數,這樣就可以避免this指向爲函數對象的問題。
new Vue( {
data: {
filterKey: 1,
testList: [1, 2, 3];
},
methods: {
filter() {
this.testList.filter(function(item) {
return item == this.filterKey // **注意這裏的filterKey 爲 undefined**
});
}
}
} );