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