- vue 限度只能输出名称32位中文,手机号11位数字,验证码6位数字
watch: { 'bindForm.name'(val) { let pattern = /[^\u4e00-\u9fa5]+/ this.bindForm.name = val.replace(pattern, '') if (val.length > 32) { this.bindForm.name = val.substring(0, 32) } this.checkIsComplete() }, 'bindForm.phone'(val) { if (val.length > 11) { this.bindForm.phone = val.substring(0, 11) } this.checkIsComplete() }, 'bindForm.code'(val) { if (val.length > 6) { this.bindForm.code = val.substring(0, 6) } this.checkIsComplete() }, }
- 获取地址栏参数
function getQueryString(name) { var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i') var reg_rewrite = new RegExp('(^|/)' + name + '/([^/]*)(/|$)', 'i') var r = window.location.search.substr(1).match(reg) var q = window.location.pathname.substr(1).match(reg_rewrite) if (r != null) { return unescape(r[2]) } else if (q != null) { return unescape(q[2]) } else { return null } }