My goal is to have the input
disabled and empty. If the LEVEL2 input is empty, then both LEVEL3 and LEVEL4 should also be disabled and empty.
If the LEVEL3 input is empty, then LEVEL4 should be disabled and empty.
The disabled code is functioning properly, but the value still remains. The current code looks like this:
<el-form-item :prop="'materialInfo.' + e_key + '.LEVEL2'" :rules="level2Rules" class="u_f_left">
<span>-</span>
<el-input v-model="e_val.LEVEL2" :value="e_val.LEVEL2" placeholder="Level 2" class="wid70" @blur="joinLevel(e_key)" clearable></el-input>
</el-form-item>
<el-form-item :prop="'materialInfo.' + e_key + '.LEVEL3'" :rules="level3Rules" class="u_f_left">
<span>-</span>
<el-input :disabled="e_val.LEVEL2?false:true" v-model="e_val.LEVEL3" :value="e_val.LEVEL3" placeholder="Level 3" class="wid70" @blur="joinLevel(e_key)" clearable></el-input>
</el-form-item>
<el-form-item :prop="'materialInfo.' + e_key + '.LEVEL4'" :rules="level4Rules" class="u_f_left">
<span>-</span>
<el-input :disabled="e_val.LEVEL3?false:true" v-model="e_val.LEVEL4" :value="e_val.LEVEL4" placeholder="Level 4" class="wid70" @blur="joinLevel(e_key)" clearable></el-input>
</el-form-item>
A screenshot of how it currently behaves can be seen here.
I've tried adjusting the conditions in the v-model
, like so:
<el-input :disabled="e_val.LEVEL2?false:true" v-model="e_val.LEVEL2?e_val.LEVEL3:EMPTYVALUE" :value="e_val.LEVEL3" placeholder="Level 3" class="wid70" @blur="joinLevel(e_key)" clearable></el-input>
The variable EMPTYVALUE
is defined as EMPTYVALUE: '',
.
However, I encountered some errors when trying this method and it did not compile successfully.
Additionally, I would prefer to avoid using the blur
or change events
if possible.