html:

<el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>

<div style="margin: 15px 0"></div>

<el-checkbox-group

v-model="checkedCities"

@change="handleCheckedCitiesChange" >

<el-checkbox

v-for="city in cities"

:label="city.cposcode"

:key="city.cposcode"

>{{ city.cposname }}</el-checkbox>

</el-checkbox-group>

js:

return:{

checkAll: false,

isIndeterminate: true,

checkedCities: [],

   cities: [{ cposname: "", cposcode: "", cwhcode: "" }],//for循环数据

citisname:[],

citiscode:[],

}

methods:{

  // 单选

    handleCheckedCitiesChange(value) {

      this.choice = value

      console.log(this.choice,"555")

    },

    // 多选

     handleCheckAllChange(val) {

        this.citiscode=[]

         this.cities.forEach((item)=>{

           //将字符串追加到数组

          this.citiscode.push(item.cposcode);

    })

        this.checkedCities = val ? this.citiscode : [];

        this.isIndeterminate = false;

        this.choice =  this.citiscode;

        console.log(this.checkedCities,"7777777")

      },

}