vue 對 v for 中陣列進行過濾操作

2022-09-17 09:09:08 字數 313 閱讀 4628

之前寫angularjs的時候,filter是可以直接在ng-repeat中使用。但是到了vue好像這個不起作用。

具體解決辦法:

加乙個計算屬性:

computed:

}

然後template中直接引用filterdata就可以了,所有過濾的操作可以直接寫在filterdata屬性的後面那個function中。

使用:

for="(item, index) in filterdata">

注: filterdata不能在data中定義,這是乙個計算屬性,否則會報錯。

vue 使用v for進行迴圈

doctype html html lang en head meta charset utf 8 meta name viewport content width device width,initial scale 1.0 script src script title vue中使用v for ...

vue 使用v for進行迴圈

doctype html html lang en head meta charset utf 8 meta name viewport content width device width,initial scale 1.0 script src script title vue中使用v for ...

vue中v for的使用

for item,index in list key index p data 結果 people1 people2 people3for index,value,key in obj p data 結果0 name 哈哈哈1 男2 age 21當他們處於同一節點,v for的優先順序高於v if,...