vue.js怎么用正则校验

vue.js用正则校验的方法:首先定义const;然后使用test方法,代码为【if(reg.test(data)){console.log("通过正则验证");}else{console.log("未通过正则验证")}}】。

vue.js怎么用正则校验

本教程操作环境:windows10系统、vue2.9,本文适用于所有品牌的电脑。

【相关文章推荐:vue.js】

vue.js用正则校验的方法:

定义 const

使用 test 方法

testMethod(data){
const reg = /^[^\u4e00-\u9fa5]{1,20}$/;
if(reg.test(data)){
console.log("通过正则验证");
}else{
        console.log("未通过正则验证")
    }
}

相关免费学习推荐:javascript(视频)

以上就是vue.js怎么用正则校验的详细内容,更多请关注www.jshuw.com其它相关文章!