//全部参数校验必填
form:{
name:'',
age:'',
address:''
},
let bool = true
Object.keys(this.form).forEach((key) => {
if (!this.form[key]) {
bool = false
}
})
if (!bool) {
uni.showToast({
title: '请填写必填项!',
icon: 'error',
})
return false
}
//指定参数校验必填
form:{
name:'',
age:'',
address:''
},
formRule:['name']
let bool = true
formRule.forEach((key) => {
if (!this.form[key]) {
bool = false
}
})
if (!bool) {
uni.showToast({
title: '请填写必填项!',
icon: 'error',
})
return false
}
自定义校验form表单
最新推荐文章于 2024-07-27 10:43:42 发布