需求
根据radio切换来更改下拉框是否多选
原因
单选和多选这两个 input 看上去没差别(自身和层级都一致),vue出于提高性能,所以 vue 给复用了
解决方案
<template>
<section>
<el-radio-group v-model="radio" @input="changeRadio">
<el-radio :label="1">单选</el-radio>
<el-radio :label="2">多选</el-radio>
</el-radio-group>
<el-select value-key="radio==2?'two':'one'" v-model="chooseVal" :multiple="radio==2" placeholder="请选择">
<el-option v-for="item in Enums.GetElementUiSelectOptions(Enums.DiseaseTypes)" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</section>
</template>
<script>
export default {
data() {
return {
radio: 1,
chooseVal:'',
};
},
mounted() {
},
methods: {
changeRadio(val){
console.log('dddd',val);
if(val==1){
this.chooseVal = '';
}else{
this.chooseVal = [];
}
},
}
};
</script>