vue-verification-code-input
vue-verification-code-input copied to clipboard
clear / reset
hi, how can clear or reset Code Input?
I think, change v-model field to empty
this.$refs.[refComponent].values = [empty array of values] solve your problem
@suweya hi, first of all much thanks for this component! And can tou please add an example with passing valuse for the component? I'm trying do it like this :values=[1,2,4,0]
but value is not setted/reseted. zerogravity2020's advice just destroy all the compoent
to empty the input fields you can use refs this way
<codeInput ref='code' v-on:complete='onCompleted'>
in a method like for example, I want to clear the fields when the user is completed all the fields
onCompleted(v) {
..........
this.$refs.code.values = ['','','','','']
}
If you want to reset the input and move the cursor to the first cell you can do it like that:
this.$refs.code.values = ['','','',''];
const name = this.$refs.code.iRefs[0];
const element = this.$refs.code.$refs[name][0];
element.focus();
element.select();