|
1 |
| -import { getCurrentInstance } from 'vue' |
| 1 | +import { getCurrentInstance, nextTick } from 'vue' |
2 | 2 | import { getLocaleMessages, SetPluralRulesSymbol } from './composer'
|
3 | 3 | import { createVueI18n } from './legacy'
|
4 | 4 | import { createI18nError, I18nErrorCodes } from './errors'
|
@@ -100,34 +100,36 @@ export function defineMixin(
|
100 | 100 | }
|
101 | 101 | },
|
102 | 102 |
|
103 |
| - beforeUnmount(): void { |
| 103 | + unmounted(): void { |
104 | 104 | const instance = getCurrentInstance()
|
105 | 105 | /* istanbul ignore if */
|
106 | 106 | if (!instance) {
|
107 | 107 | throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR)
|
108 | 108 | }
|
109 | 109 |
|
110 |
| - /* istanbul ignore if */ |
111 |
| - if ((__DEV__ || __FEATURE_PROD_VUE_DEVTOOLS__) && !__NODE_JS__) { |
112 |
| - if (this.__v_emitter) { |
113 |
| - this.__v_emitter.off('*', addTimelineEvent) |
114 |
| - delete this.__v_emitter |
| 110 | + nextTick(() => { |
| 111 | + /* istanbul ignore if */ |
| 112 | + if ((__DEV__ || __FEATURE_PROD_VUE_DEVTOOLS__) && !__NODE_JS__) { |
| 113 | + if (this.__v_emitter) { |
| 114 | + this.__v_emitter.off('*', addTimelineEvent) |
| 115 | + delete this.__v_emitter |
| 116 | + } |
| 117 | + const _vueI18n = (this.$i18n as unknown) as VueI18nInternal |
| 118 | + _vueI18n.__disableEmitter && _vueI18n.__disableEmitter() |
| 119 | + delete this.$el.__VUE_I18N__ |
115 | 120 | }
|
116 |
| - const _vueI18n = (this.$i18n as unknown) as VueI18nInternal |
117 |
| - _vueI18n.__disableEmitter && _vueI18n.__disableEmitter() |
118 |
| - delete this.$el.__VUE_I18N__ |
119 |
| - } |
120 | 121 |
|
121 |
| - delete this.$t |
122 |
| - delete this.$rt |
123 |
| - delete this.$tc |
124 |
| - delete this.$te |
125 |
| - delete this.$d |
126 |
| - delete this.$n |
127 |
| - delete this.$tm |
| 122 | + delete this.$t |
| 123 | + delete this.$rt |
| 124 | + delete this.$tc |
| 125 | + delete this.$te |
| 126 | + delete this.$d |
| 127 | + delete this.$n |
| 128 | + delete this.$tm |
128 | 129 |
|
129 |
| - i18n.__deleteInstance(instance) |
130 |
| - delete this.$i18n |
| 130 | + i18n.__deleteInstance(instance) |
| 131 | + delete this.$i18n |
| 132 | + }) |
131 | 133 | }
|
132 | 134 | }
|
133 | 135 | }
|
|
0 commit comments