let exp = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
let reg = this.datasd.targetIp.match(exp);
if (reg == null) {
this.$message.error("IP地址不合法!请输入正确的IP地址");
} else {
console.log("datasd", this.datasd);
}
其中this.datasd.targetIp是你输入的ip值,拿来判断

网友评论