From da0bcfc7874558d16827c5914116d581654407cb Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Wed, 26 Jan 2022 14:16:05 +0800 Subject: [PATCH] fix(mp): delay flush jobs (#3228) --- packages/uni-mp-vue/lib/vue.runtime.esm.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/uni-mp-vue/lib/vue.runtime.esm.js b/packages/uni-mp-vue/lib/vue.runtime.esm.js index 75b49479c7..84bc5c9bca 100644 --- a/packages/uni-mp-vue/lib/vue.runtime.esm.js +++ b/packages/uni-mp-vue/lib/vue.runtime.esm.js @@ -1413,10 +1413,17 @@ function queueJob(job) { queueFlush(); } } +// fixed by xxxxxx +function sleep(ms) { + return () => { + return new Promise(resolve => setTimeout(() => resolve(void 0), ms)); + }; +} function queueFlush() { if (!isFlushing && !isFlushPending) { isFlushPending = true; - currentFlushPromise = resolvedPromise.then(flushJobs); + // fixed by xxxxxx 延迟执行,避免同一批次的事件执行时机不正确,对性能可能有略微影响 https://github.com/dcloudio/uni-app/issues/3228 + currentFlushPromise = resolvedPromise.then(sleep(0)).then(flushJobs); } } function invalidateJob(job) { -- GitLab