common下封装常用函数
文件:StrUtils.js
//文件主要写的是会经常使用到的工具类
//校验邮箱格式
function checkEmail(email){
return RegExp(/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/).test(email);
}
//校验手机格式
function checkMobile(mobile){
return RegExp(/^1[34578]\d{9}$/).test(mobile);
}
module.exports = {
checkEmail : checkEmail,
checkMobile : checkMobile
}
引用
方式一:var config1 = require("../../utils/config.js");
方式二:import md5 from "@/common/StrUtils.js";
调用:StrUtils.checkEmail("xcSharp@126.com")