修复v-form在调用validate时promise有大几率一直pending状态#1107
Open
79229788 wants to merge 1 commit intoumicro:masterfrom
Open
修复v-form在调用validate时promise有大几率一直pending状态#110779229788 wants to merge 1 commit intoumicro:masterfrom
79229788 wants to merge 1 commit intoumicro:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BUG效果:this.$refs.form.validate(); 经常无反应,既没有then也没有catch,首次可以,二次之后就经常要执行多次才有效果,反复无常
问题点:
源码简化后的代码就是两层$nextTick,即如下:
this.$nextTick(() => {
.....this.$nextTick(() => {
..........在没有更新新数据时,这里不会执行(这里放着promise的resolve和reject,不执行那肯定是pending),删掉第二层重复的$nextTick即可解决
.....})
});
因为要等2次队列更新,所以第一次更新数据后进入this.validateField,第二层里面的nextTick就大概率不会再执行了,那么promise就一直是pending。那么只需要删除第二层的nextTick即可解决