Answer the question
In order to leave comments, you need to log in
VueJS how to do v-if with condition if input is more than 2 characters?
There is a layout that is divided into steps. The next step is activated if some action was performed in the previous step. In this case, if something is written to input, then the next step is activated. But the problem is that at first I have a currency sign in the input, and v-if works immediately, I would like to know how to make v-if work only when there are more than 2 characters in the input?
The input itself:
<div class="buy-voucher__amounts">
<input class="buy-voucher__custom-input" id="value-custom__voucher" v-on:input="changeVoucherCustom" v-model="CustomVoucherCount">
</div>
<div class="booking__step" v-if="changeVoucherCustom">
Answer the question
In order to leave comments, you need to log in
The concept is like this:
<div class="booking__step" v-if="showStep">
data: {
customVoucherCount: '$',
showStep: false;
},
watch: {
// эта функция запускается при любом изменении id="value-custom__voucher"
customVoucherCount: function (newCount, oldCount) {
this.showStep = newCount.lenght > 2 ? true : false;
}
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question