Home > Article > Web Front-end > How to use regular verification in vue.js
Vue.js uses regular verification method: first define const; then use the test method, the code is [if(reg.test(data)){console.log("pass regular verification");} else{console.log("Failed regular verification")}}].
The operating environment of this tutorial: windows10 system, vue2.9, this article is applicable to all brands of computers.
【Recommended related articles: vue.js】
Vue.js uses regular verification method:
Definition const
Use test method
testMethod(data){ const reg = /^[^\u4e00-\u9fa5]{1,20}$/; if(reg.test(data)){ console.log("通过正则验证"); }else{ console.log("未通过正则验证") } }
Related free learning recommendations: javascript(Video)
The above is the detailed content of How to use regular verification in vue.js. For more information, please follow other related articles on the PHP Chinese website!