Skip to content

Commit

Permalink
fix(u-form):修改rules提示引起的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-qianjue committed Feb 10, 2022
1 parent 858b999 commit ee55102
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions uni_modules/uview-ui/components/u-form/u-form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,7 @@
});
},
// 对部分表单字段进行校验
async validateField(value, callback, event = null) {
// 开发环境才提示,生产环境不会提示
if (process.env.NODE_ENV === 'development' && Object.keys(this.formRules).length === 0) {
uni.$u.error('未设置rules,请看文档说明!如果已经设置,请刷新页面。');
return;
}
async validateField(value, callback, event = null) {
// $nextTick是必须的,否则model的变更,可能会延后于此方法的执行
this.$nextTick(() => {
// 校验错误信息,返回给回调方法,用于存放所有form-item的错误信息
Expand Down Expand Up @@ -186,7 +181,12 @@
});
},
// 校验全部数据
validate(callback) {
validate(callback) {
// 开发环境才提示,生产环境不会提示
if (process.env.NODE_ENV === 'development' && Object.keys(this.formRules).length === 0) {
uni.$u.error('未设置rules,请看文档说明!如果已经设置,请刷新页面。');
return;
}
return new Promise((resolve, reject) => {
// $nextTick是必须的,否则model的变更,可能会延后于validate方法
this.$nextTick(() => {
Expand Down

0 comments on commit ee55102

Please sign in to comment.