设置async-close异步关闭
<u-modal ref="uModal" v-model="show" width="85%" title="原因" confirm-text="确定" :async-close="true" show-cancel-button @confirm="confirm" @cancel="cancel">
<view class="slot-content">
<u-form ref="uForm" :model="form" label-width="80">
<u-form-item label="原因" prop="remark" required>
<u-input v-model="form.remark" placeholder="请输入原因" type="textarea" border :height="100" auto-height />
</u-form-item>
</u-form>
</view>
</u-modal>
提交表单验证
confirm() {
this.$refs.uForm.validate((valid) => {
if (valid) {
// 验证通过...
} else {
// 校验失败,清除loading
this.$nextTick(() => {
this.$refs.uModal.clearLoading()
})
}
})
},
使用setRules()设置验证规则
data() {
return {
show: true,
rules: {
remark: [
{
required: true,
message: '请输入原因!',
trigger: ['change', 'blur']
}
]
},
form: {
eremark: ''
}
}
},
onReady() {
this.$refs.uForm.setRules(this.rules)
},
标签:setRules,验证,refs,uview,表单,uForm,true,弹窗
From: https://blog.csdn.net/Joan_OvO/article/details/132831012