vue動態禁用控制元件繫結disable
場景
報修範圍取值不同時 ,區域有時需要禁用
程式碼
<el-form-item label="報修範圍" prop="applicationRange" >
<el-select v-model="addInfo.applicationRange" placeholder="請選擇報修範圍" style="width: 200px" @change="inputToDisabled" >
<el-option v-for="item in applicationRangeList" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="區域" prop="areaCodeAdd">
<el-select v-model="addInfo.areaCodeAdd" placeholder="請選擇區域" v-on:change="getBuildListAdd" style="width: 220px" :disabled="isAble"
<el-option
v-for="item in areaListAdd"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
methods:{
inputToDisabled (){
if (this.addInfo.applicationRange === '1002') {
this.isAble = true; // 注意true是不可用
} else{
this.isAble = false; //可用
}
},
}