组件el-check-tag、el-tag实现点击高亮(多选)

  • Post author:
  • Post category:其他
 <el-form-item label="薪酬福利" prop="welfare">
          <!-- <el-select v-model="form.welfare" class="m-2" placeholder="请选择薪酬福利" filterable>
            <el-option v-for="item in state.gwflOptions" :key="item.value" :label="item.label" :value="item.value" />
          </el-select> -->

          <el-check-tag
            class="welfare"
            :class="{active:state.labelCodeList.indexOf(item.value)!=-1}"
            v-model="form.welfare"
            v-for="item in state.gwflOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
            @change="onChange(item.value)"

            >{{ item.label }}</el-check-tag
          >
        </el-form-item>
//职位诱惑
const onChange = (val) => {

  if(state.labelCodeList.indexOf(val)!=-1){
    state.labelCodeList.splice(state.labelCodeList.indexOf(val),1)
  }else{
    state.labelCodeList.push(val)
  }
}


版权声明:本文为ZDM_9999原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。