vue常见问题处理

插值表达式加载闪烁问题:

<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**    
             });
         }
    }
} );
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章