vue.js实现CheckBox与数组对象绑定

vue实现CheckBox与数组对象绑定

实际应用中,这个get(),有问题。我暂时注释掉了,

    computed: {
        alertPageShopsCheckAll: {
            get() {
                let result = true;
                for (let i = 0; i < this.curAlertPageShopList.length; i++) {
                    if (!this.curAlertPageShopList[i].selected){
                        result = false;
                    }
                }
                return result;
            },
            set(val) {
                for (let i = 0; i < this.curAlertPageShopList.length; i++) {
                    this.curAlertPageShopList[i].selected = val;
                }
            }
        },
    },

直接在Data增加变量

alertPageShopsCheckAll: false,

另外需要研究一下

handleCheckAll,get,set之间的关系

 

你可能感兴趣的:(前端)