el-checkbox-group全选无效问题

el-checkbox-group的label绑定的是el-checkbox中的label属性,并非是key属性。

<div style="margin-top: 20px">
            <template>
                <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
                <div style="margin: 15px 0;"></div>
                <el-checkbox-group v-model="checkboxGroup" @change="handleCheckedShopChange">
                    <el-checkbox v-for="shop in shoplist" :label="shop.shopid" >{{shop.shopname}}</el-checkbox>
                </el-checkbox-group>
            </template>
        </div>
全选
```javascript
handleCheckAllChange(val) {
                var checkedsItem = val ? this.shoplist : []
                if (checkedsItem.length > 0) {
                    checkedsItem.map(item => {
                        this.checkboxGroup.push(item.shopid)
                    })
                } else {
                    this.checkboxGroup = []
                }
                console.log(this.checkboxGroup)
                this.isIndeterminate = false;
            },

你可能感兴趣的:(技术,javascript,前端,vue.js)