Vue Js v-model on v-select shows wrong value
P粉697408921
P粉697408921 2023-08-30 16:52:46
0
1
435
<p>There is some kind of bug on my v-select that causes v-model to display a different value than the actual value of the variable. I use a method to change the selected option that applies to the first change. For example, if I select False and flag = Y, the selected option changes to True, this works the first time you select the option, then when I change the value from True to False, it changes value, but the selected option is still false. </p> <pre class="brush:html;toolbar:false;"><v-col cols="9"> <v-select v-model="promo_form.generate_voucher" @input="methodUsed" :rules="textInputRules" :items="['False', 'True']" required outlined ></v-select> </v-col> </pre> <p>This is the method I use: </p> <pre class="brush:js;toolbar:false;">if(this.flag_member == 'N' && this.promo_form.generate_voucher == 'True'){ this.promo_form.promo_id = null; this.flag_member = ""; this.promo_form.generate_voucher = null; this.promo_form.voucher_type = ""; this.flag1 = 'y'; } else if(this.flag_member == 'Y' && this.promo_form.generate_voucher == "False"){ this.promo_form.generate_voucher = "True"; this.flag1 = 'n' } if(this.flag1 == 'y'){ alert('Something') } else if(this.flag1 == 'n'){ alert("Something") } </pre> <p>I tried adding a label and the value is correct for the label but not for the v-model</p>
P粉697408921
P粉697408921

reply all(1)
P粉473363527

In the method try changing this line

this.promo_form.generate_voucher = null
to
this.promo_form.generate_voucher = 'False'
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template