这是我的代码笔链接https://codepen.io/santoshch/pen/LYxOoWO
<button @click="resetNow(id)"></button>
resetNow(id){
this.$refs[`input-${id}`].input.value = ""; //You may need to use .$el.value instead of .input.value
}
尝试重置输入OTP字段的值,但未重置该值。
好的,所以我不确定为什么,但它实际上可以使用以下代码:
resetNow() {
this.activationKeyFields.forEach((_, index) => this.$refs[`input-${index}`][0].value = "")
},
因此,点击
<button @click="resetNow">reset</button>
它正确地取消了所有字段的内容。