方法
// 数字验证
isIntNum(row, type, max, min) {
let str = String(row[type]);
console.log(str, "str");
// console.log(row[type])
// var regPos = /^\d+$/; // 非负整数
var regPos = min == 1 ? /^\d+$/ : /-?\d+(\.\d+)?/; // 非负数
var pattern = new RegExp(
"[`-~!@#$^&*()=|{}':;',\\[\\]<>《》/?~!@#¥……&*()——|{}【】‘;:”“'。,、? ]"
);
// var regNeg = /^\-[1-9][0-9]*$/; // 负整数
if (!regPos.test(row[type])) {
// row[type] = ''
this.$set(row, type, "");
}
if (pattern.test(row[type])) {
this.$set(row, type, str.slice(0, str.length - 1));
console.log(row[type], "pattern");
}
console.log(row[type], "row[type]");
if (Number(row[type]) > Number(max)) {
this.$set(row, type, str.slice(0, str.length - 1));
// row[type] = str.slice(0, str.length - 1)
}
if (Number(row[type]) < Number(min)) {
this.$set(row, type, "");
// row[type] = str.slice(0, str.length - 1)
}
let z = row[type].split(".");
console.log("z", z);
if (z.length > 2) {
this.$set(row, type, str.slice(0, str.length - 1));
}
if (z.length == 2) {
if (z[0].length > 6 || z[1].length > 2) {
this.$set(row, type, str.slice(0, str.length - 1));
}
}
// this.$set(row, type, Number(str).toFixed(2));
},
2 条评论
你的文章充满了欢乐,让人忍不住一笑。 http://www.55baobei.com/HbdDFYqtVz.html
文章的确不错啊https://www.cscnn.com/