<form-item :label="'DNS'+(index+1)" :prop="'dnsList2.' + index + '.dns'" :rules="isV4OrV6Dns">
<i-input v-model="list.dns" placeholder="请输入DNS" :disabled="!hsP"></i-input>
</form-item>
isV4OrV6Dns放在计算属性
isV4OrV6Dns(){
return {
required: true, validator: (rule, value, callback)=>{
if (!isEmpty(value)) {
callback(new Error('请输入DNS地址'));
}else if(!isIPv4(value)&&!isIPv6(value)){
callback(new Error('请正确输入DNS地址'));
}else {
callback();
}
},
trigger: 'blur'
}
}
来源:https://blog.csdn.net/bbsyi/article/details/100977044