点击 element el-checkbox-group复选框前面的框才能选中,点击后面的文字不让选中

<el-checkbox-group class="flex flex-col" v-model="checkedMessage">
  <el-checkbox @click="checkOnlyOnBox" class="margin-bottom-12 border-bottom" v-for="city in messageList" :key="city.key"
      :label="city.key" :alt="city.label">
      {{ city.label }}
  </el-checkbox>
</el-checkbox-group>
function checkOnlyOnBox(event: any){
  if("el-checkbox__inner" != event.target.className){
  //点击的不是前面的小框框,阻止默认行为
event.preventDefault(); }else{ //点击的是前面的小框框 } }

 

posted @ 2024-10-12 15:47  龙卷风吹毁停车场  阅读(88)  评论(0编辑  收藏  举报