Home  >  Article  >  Web Front-end  >  How to use regular verification in vue.js

How to use regular verification in vue.js

coldplay.xixi
coldplay.xixiOriginal
2020-11-09 15:12:255898browse

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")}}].

How to use regular verification in vue.js

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn