vue使用正则验证

vue 使用正则验证

  • 定义 const
  • 使用 test 方法
testMethod(data){
	const reg = /^[^\u4e00-\u9fa5]{1,20}$/;
	if(reg.test(data)){
		console.log("通过正则验证");
	}else{
        console.log("未通过正则验证")
    }
}
posted @ 2020-10-15 18:08  ch-一念之间  阅读(6570)  评论(0)    收藏  举报