// vue
<u-input
class="input-style m-b-8"
v-model="emailAddress"
:type="type"
:border="border"
:trim="trim"
@blur="doInput(emailAddress)"
placeholder="请输入您的邮箱地址"
/>
// 验证邮箱地址格式
doInput(val) {
const emailReg =
/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if (!emailReg.test(val)) {
uni.showToast({
title: '邮箱地址格式错误',
icon: 'none'
});
return;
}
}
uniapp的showToast API:https://uniapp.dcloud.io/api/ui/prompt?id=showtoast
uview-ui的input组件:https://www.uviewui.com/components/input.html