在制作一个根据props传入值来动态生成未知个数的el-checkbox-group时:
<template>
<div >
<el-checkbox-group v-for="(items,key) in queryData" v-model="checked[key]" @change="handleChange">
<el-checkbox v-for="item in items" :label="item.value">{
{item.name}}</el-checkbox>
</el-checkbox-group>
</div>
</template>
<script>
export default {
name: 'MySearch',
data() {
return {
checked: {}
}
},
props: {
queryData: {
type: Object,
required: true
}
},
methods: {
handleChange() {
this.$emit('change', this.checked)
}
}
}
</script>
遇到一个问题,element-ui的el-checkbox-group需要绑定一个Array数组,但th