插值表达式加载闪烁问题:
<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**
});
}
}
} );