https://jsfiddle.net/72tnpa0o/Vue.js - 重置filterBy導致
<div id="filter-by-example">
<label>Cool</label><input type="checkbox" v-model="cool">
<label>notCool</label><input type="checkbox" v-model="notCool">
<ul>
<li v-for="user in users | filterBy cool in 'cool' | filterBy notCool in 'notCool'">
{{ user.name }}
</li>
</ul>
</div>`
new Vue({
el: '#filter-by-example',
data: {
name: '',
users: [
{
name: 'Bruce',
cool: true,
notCool: false
},
{
name: 'Chuck',
cool: false,
notCool: true
},
{
name: 'Jackie',
cool: true,
notCool: false
}
]
}
})
我有一個例如高達在高於小提琴鏈路。我可以通過輸入複選框進行排序,但取消選中篩選器不會重置爲原始結果。
有沒有人知道如何取消選中過濾器按鈕來獲取完整的數組呈現?
嘗試**阿爾弗雷多·EM **的答案。它完美地工作。 https://jsfiddle.net/72tnpa0o/4/ – imrealashu
阿爾弗雷多的解決方案的問題是,它忽略了你的代碼有錯誤的事實。應該事先在組件中定義'cool'和'notCool'。在瀏覽器中打開控制檯並更改複選框:您會看到Vue警告像瘋了一樣燃燒。 –