标签:username vue 重复 phone 用户名 error message true
#前端函数如下,js方法代码无需更改,前端代码逻辑components\common\lab_header.vue`
#只需要修改components\axios_api\http.js
中调用的后端地址
// axios.defaults.baseURL = "http://127.0.0.1:8000/"
axios.defaults.baseURL = "http://192.168.56.100:8888/"
// 检查用户名 是否使用 check_username() { console.log('判断用户名') console.log(this.username == '') var reg = new RegExp(/^[a-zA-Z0-9_-]{3,16}$/); //字符串正则表达式 4到14位(字母,数字,下划线,减号) if (this.username == '') { this.username_message = '用户名不能为空' this.username_error = true return false } if (!reg.test(this.username)) { this.username_message = '用户名格式不正确' this.username_error = true return false } else { // 去后端检查用户名使用数量 user_count({ type: 'username', data: this.username }).then((res) => { console.log(res) if (res.data.count > 0) { this.username_message = '用户名已存在' this.username_error = true } else { this.username_message = '' this.username_error = false } }) } },
vue检查手机号是否重复
// 检查手机号是否使用 check_phone() { console.log('检查手机号') var reg = new RegExp(/^[1]([3-9])[0-9]{9}$/) if (this.phone == '') { this.phone_message = '手机号不能为空' this.phone_error = true } if (!reg.test(this.phone)) { this.phone_message = '手机号格式不正确' this.phone_error = true return false } else { // 去后端查用户数量 user_count({ type: 'phone', data: this.phone }).then((res) => { console.log(res) if (res.data.count > 0) { this.phone_message = '手机号已存在' this.phone_error = true } else { this.phone_message = '' this.phone_error = false } }) } },
标签:username,vue,重复,phone,用户名,error,message,true 来源: https://www.cnblogs.com/shanjiaaa/p/13779386.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。