提交 ffce0b26 编写于 作者: Q qiang

fix: app-v3 $nextTick 支持返回 Promise

上级 ce1f7f06
......@@ -54,16 +54,18 @@ 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)
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册