這里的計(jì)算屬性是需要根據(jù)路由的參數(shù)來過濾一下,但是過濾后的result數(shù)組應(yīng)該已經(jīng)和this.list沒有關(guān)系了,所以失去的雙向綁定的功能,求助有什么好點(diǎn)方案來解決這個(gè)問題嗎?export default{ data(){ return { currentCate: null, list: Store.fetch() } }, watch: { '$route' (to, from) { this.updataCate(); } }, created(){ this.updataCate(); }, computed: { viewData(){ let result = []; this.list.forEach((item, index) => { if(item.cate && item.cate == this.currentCate){ result.push(item); } }); return result; } }, methods: { updataCate(){ this.currentCate = this.$route.params.cate; }, toggleCompleted(item){ // var index = this.items.indexOf(item) // console.log(index); item.completed = !item.completed; } }}
關(guān)于vue的模版數(shù)據(jù)被計(jì)算屬性過濾后失去雙向綁定的問題!
紅糖糍粑
2018-11-12 13:15:26