//防抖.
methods:{
debounce(fn, wait) {
if (this.timer !== null) {
clearTimeout(this.timer);
}
this.timer = setTimeout(fn, wait);
},
//校验证件号码是否未成年
check() {
let num = this.stepOneform.cernumber.substring(6, 10);
let now = new Date().getFullYear();
console.log(num);
console.log(now);
if (now - num < 18) {
this.$message.error("请输入已成年的证件号码");
}
},
},
watch: {
"stepOneform.cernumber": {
deep: true,
handler(newVal) {
if (newVal.trim().length !== 0) {
this.debounce(this.check, 1000);
}
},
},
},
小小小防抖,检验输入的证件号码是否大于18
最新推荐文章于 2024-06-13 14:23:28 发布