From ffce0b26e38904987467b5c9c79b14cd71a23874 Mon Sep 17 00:00:00 2001 From: qiang Date: Mon, 17 Feb 2020 11:39:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20app-v3=20$nextTick=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=20Promise?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app-plus/service/framework/plugins/index.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/platforms/app-plus/service/framework/plugins/index.js b/src/platforms/app-plus/service/framework/plugins/index.js index f477de6b5c..aa90011a42 100644 --- a/src/platforms/app-plus/service/framework/plugins/index.js +++ b/src/platforms/app-plus/service/framework/plugins/index.js @@ -54,17 +54,19 @@ export default { Vue.prototype.$nextTick = function nextTick (cb) { const renderWatcher = this._watcher + const callback = typeof cb === 'function' if ( renderWatcher && this._$queue.find(watcher => renderWatcher === watcher) ) { - vdSyncCallbacks.push(cb.bind(this)) + const result = new Promise((resolve) => { + vdSyncCallbacks.push(callback ? cb.bind(this) : resolve) + }) + return callback ? result : undefined } else { // $nextTick bind vm context - Vue.nextTick(() => { - cb.call(this) - }) + return Vue.nextTick(callback ? () => cb.call(this) : undefined) } } } -} +} -- GitLab