// 验证身份证正则表达
let regID = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
处理号码
let reg = /(\d{3})\d{5}(\d{3})/g
this.phone = res.data.data.userInfo.user_tel.replace(reg, '$1*****$2')
//手机号码
/^1[3|5|6|7|8|9]\d{9}$/gi
密码输入框过滤只能输入数字
<input type="password">
let reg = /^[a-z]|[A-Z]|\s|\D/gi
input 限制不能输入中文
@keyup="phone = phone.replace(/[\u4e00-\u9fa5]/ig,'')"
// 获取url地址参数,以?拼接类型,如: http://www.xxx.com/cloud/Index/contactCardsDetail.html?cardType=1&cardId=1990
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null){
return unescape(r[2]);
}else{
return getQueryString2(name);
}
}
// 获取url地址参数,以/拼接类型,如: http://www.xxx.com/cloud/Personal/otherCard/cardUserId/42344.html
function getQueryString2(name) {
var reg = new RegExp("\/" + name + "\/([\\d\\w_]*)(\\.|\/)", "i");
var r = window.location.pathname.match(reg);
if (r != null) return unescape(r[1]); return null;
}
// js其它方法获取url上的参数 ie不支持
let urlParams = new URLSearchParams(window.location.search)
let _id = urlParams.get('id')
// 只能输入中文、英文、数字
let val = str.replace(/[^\u4E00-\u9FA5A-Za-z0-9]/g, '')