Adding a :validate-event="false" attribute to the el-input tag will eliminate the need to verify the legality of the value during the input process. It will only be verified when the submit button is clicked:
// ......
<el-form :inline="true" :model="formData" ref="formDataRef" :rules="formRules">
<el-form-item v-else label="IP地址:" prop="ip">
<el-input
class="ip-ipt"
ref="ipInput0"
:validate-event="false"
v-model="ipArr[0]"
maxlength="3"
@input="nextFocus(0)" />
</el-form-item>
</form>
// ......
let formRules = ref({
ip: { required: true, trigger: ['blur', 'change'], message: '请输入正确的IP地址' }
});
const formDataRef= ref();
// ......
// 提交事件
const onSubmit = () => {
ipInput.value.validate((valid: boolean) => {
if (valid) {}
})
}