From 311b8f3c8db693270d9acff198ef94643fd73f08 Mon Sep 17 00:00:00 2001 From: MASONGZHI <511071161@qq.com> Date: Mon, 14 Jan 2019 07:14:05 +0800 Subject: [PATCH] :bug: bug(mixin): fix beforeDestroy can not find this.$t (#500) by @masongzhi --- src/mixin.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/mixin.js b/src/mixin.js index 55fae110a..cbf2debf3 100644 --- a/src/mixin.js +++ b/src/mixin.js @@ -85,21 +85,24 @@ export default { beforeDestroy (): void { if (!this._i18n) { return } - if (this._subscribing) { - this._i18n.unsubscribeDataChanging(this) - delete this._subscribing - } + const self = this + this.$nextTick(() => { + if (self._subscribing) { + self._i18n.unsubscribeDataChanging(self) + delete self._subscribing + } - if (this._i18nWatcher) { - this._i18nWatcher() - delete this._i18nWatcher - } + if (self._i18nWatcher) { + self._i18nWatcher() + delete self._i18nWatcher + } - if (this._localeWatcher) { - this._localeWatcher() - delete this._localeWatcher - } + if (self._localeWatcher) { + self._localeWatcher() + delete self._localeWatcher + } - this._i18n = null + self._i18n = null + }) } }