Skip to content

Commit

Permalink
🐛 bug(mixin): fix beforeDestroy can not find this.$t (#500) by @mason…
Browse files Browse the repository at this point in the history
  • Loading branch information
masongzhi authored and kazupon committed Jan 13, 2019
1 parent 8d7df7c commit 311b8f3
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}
}

0 comments on commit 311b8f3

Please sign in to comment.