放代码:
<input class="code" type="text" maxlength="8" v-model="code" oninput="if(>8)value=(0,8)"
placeholder="Enter invitation code" @input="handleInput" @="checking" />
因为需求要限制输入位数,不需要可自己去掉
const code = ref("");
const handleInput = (event) => {
let value =
value = (/[^\d]/g, '').replace(/^[eE]/, '').replace(/[eE][+\-]?[0-9]*/, '')
//输入位数限制
if ( > 8) {
value = (0, 8)
}
= value
}
原理还是利用正则过滤掉不需要的字符