JS中先集中写个弹框,后面直接引用就行啦
showToastFun(text, type) {
wx.showToast({
title: text,
icon: type,
duration: 2000
})
},
记得在填入手机号的时候加个正则的判断哦
commit() {
if (this.data.tel == '') {
this.showToastFun('请输入手机号码', 'none')
return false
}
let pattern = /^1[34578]\d{9}$/; //验证手机号正则表达式
if (!pattern.test(this.data.tel)) {
wx.showToast({
title: '手机号码格式不正确',
icon: 'none'
})
return false
}
}