之前寫angularjs的時候,filter是可以直接在ng-repeat中使用。但是到了vue好像這個不起作用。
具體解決辦法:
加一個計算屬性:
computed:{ filterData: function () { console.log(JSON.parse(JSON.stringify(this.data))); return JSON.parse(JSON.stringify(this.data)); } }
然后template中直接引用filterData就可以了,所有過濾的操作可以直接寫在filterData屬性的后面那個function中。
使用:
<Row v-for="(item, index) in filterData"> </Row>
注: filterData不能在data中定義,這是一個計算屬性,否則會報錯。