Javascript 如何禁用按钮,直到用户在Vuejs的Otp字段中输入数字?
Javascript 如何禁用按钮,直到用户在Vuejs的Otp字段中输入数字?,javascript,vue.js,Javascript,Vue.js,验证 您可以在更改时使用,或在完成时使用 请像这样试试 <v-otp-input ref="otpInput" input-classes="otp-number" separator=" " :num-inputs="4" :should-auto-focus="true" :is-input-num="true"
验证
您可以在更改时使用,
或在完成时使用
请像这样试试
<v-otp-input
ref="otpInput"
input-classes="otp-number"
separator=" "
:num-inputs="4"
:should-auto-focus="true"
:is-input-num="true"
@on-change="handleOnChange"
@on-complete="handleOnComplete"
/>
<button class="verify-button" v-on:click="isFadeout = true" :disabled="!otp_complete" >VERIFY</button>
...
data() {
return {
otp_value: '',
otp_complete: false
},
methods: {
handleOnComplete(value) {
this.otp_complete = true;
this.otp_value = value;
},
handleOnChange(value) {
this.otp_value = value;
},
},
...
显示更多代码<如果v-otp-input
数据中有v-otp-input
字段,并且v-otp-input
组件将该字段用作v-model
<button class="verify-button" v-on:click="isFadeout = true" :disabled="otp_value.length < 4" >VERIFY</button>