无法在组件上呈现更新的列表。 组件如下:
Vue.component('c-item',{
data:function(){
return {
list: [{id:1,item:'s1'},{id:2,item:'s2'},{id:3,item:'s3'}]
};
},
methods:{
deleterow: function (id) {
this.list = this.list.filter(function (i) {
return i.id !== id;
});
alert(this.list.length); //lenght is reduced by 1.
this.$forceUpdate(); ///explicitly adding this to render UI again.
},
...
});