VueJS组件:无法获取渲染更新的集合

时间:2018-09-10 19:38:06

标签: vue.js vuejs2 vue-component

无法在组件上呈现更新的列表。 组件如下:

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.
            },
...
});

0 个答案:

没有答案