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

How to use regular verification in vue.js

coldplay.xixi
Release: 2020-11-30 11:32:42
Original
5963 people have browsed it

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("未通过正则验证")
    }
}
Copy after login

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!

Related labels:
Statement of this Website
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
Latest Issues
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template