Skip to content

修复v-form在调用validate时promise有大几率一直pending状态#1107

Open
79229788 wants to merge 1 commit intoumicro:masterfrom
79229788:master
Open

修复v-form在调用validate时promise有大几率一直pending状态#1107
79229788 wants to merge 1 commit intoumicro:masterfrom
79229788:master

Conversation

@79229788
Copy link
Copy Markdown

@79229788 79229788 commented Nov 4, 2024

BUG效果:this.$refs.form.validate(); 经常无反应,既没有then也没有catch,首次可以,二次之后就经常要执行多次才有效果,反复无常

问题点:
源码简化后的代码就是两层$nextTick,即如下:
this.$nextTick(() => {
.....this.$nextTick(() => {
..........在没有更新新数据时,这里不会执行(这里放着promise的resolve和reject,不执行那肯定是pending),删掉第二层重复的$nextTick即可解决
.....})
});

因为要等2次队列更新,所以第一次更新数据后进入this.validateField,第二层里面的nextTick就大概率不会再执行了,那么promise就一直是pending。那么只需要删除第二层的nextTick即可解决

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant