【ElementUI】复选框 el-checkbox

时间:2025-01-19 16:43:20

复选框组

<el-checkbox-group v-model="checkList">
  <el-checkbox label="复选框 A"></el-checkbox>
  <el-checkbox label="复选框 B"></el-checkbox>
</el-checkbox-group>

checkbox 选中id而不是label

可以label赋值id,中间写成label

<el-checkbox-group v-model="checkList">
  <el-checkbox label="1">{{复选框 A}}</el-checkbox>
  <el-checkbox label="2">{{复选框 B}}</el-checkbox>
</el-checkbox-group>

回填出错

label是id值,必须是string类型。

<el-checkbox-group v-model="checked">
    <el-checkbox v-for="item in list" :key="" :label="">{{}}</el-checkbox>
</el-checkbox-group>
checked: [],
list: [
    {
        id: 1,
        name: '选项一'
    }, 
    {
        id: 2,
        name: '选项二'
    }
]