How to solve the problem of vue-i18n internationalization probability error: Cannot read property'_ t'of null?

using internationalized plug-ins in vue projects will cause probabilistic errors when switching pages.: Uncaught TypeError: Cannot read property"_ t"of null at VueComponent.Vue.$t, keeps repeating errors in an orderly manner (for example, 4 errors at a time). If I refresh the page, the error will stop.

clipboard.png

Dec.02,2021

vue project, when the route jumps quickly, vue-18n has a certain probability of reporting an error Cannot read property'_ t'of null.

reason (my own understanding):
page An and page B are configured in multiple languages, such as
$t ('xxx') in html, this.$t (' xxx') in data or method.
when page A jumps to page B, the multilingual loading of page An is not finished but has already jumped to page B, so the this in page A cannot be found.

solution:
multilingual configuration file (my project is i18n/index.js under src)

import Vue from 'vue'
import VueI18n from 'vue-i18n'

import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
import enLocale from 'element-ui/lib/locale/lang/en'
import jaLocale from 'element-ui/lib/locale/lang/ja'

Vue.use(VueI18n) // 

let messages = {
  'zh-CN': { ...require('./zh'), ...zhLocale },
  'en-US': { ...require('./en'), ...enLocale },
  'ja-JP': { ...require('./ja'), ...jaLocale },
}

const i18n = new VueI18n({
  locale: 'zh-CN', // 
  messages
})

export default i18n

change this.$t ('xxx') to i18n.t (' xxx') from i18n
page to i18n.t ('xxx')

when configuring a single page with multiple languages.
import i18n from '@/i18n/index'
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b312be-e2c1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b312be-e2c1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?