Vue国际化四 -- 本地缓存

import { setLang } from "@/utils/auth"
import context from "@/main"
const state = {
  lang: 'cn'
}
const mutations = {
  SET_NEW_LANGUAGE: (state, command) => {
    switch (command) {
      case 'ZH':
        context.$i18n.locale = 'cn'
        state.lang = 'cn'
        setLang(state.lang)
        break;
      case 'EN':
        context.$i18n.locale = 'en'
        state.lang = 'en'
        setLang(state.lang)
        break;
      case 'JP':
        context.$i18n.locale = 'ja'
        state.lang = 'ja'
        setLang(state.lang)
        break;
    }
  },
  GET_LIST: (state, val) => {
    state.idsList = val
  }
}
const actions = {}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}
上一篇:报错Missing message: “menu.xxx“ for locale: “zh-CN“


下一篇:locale::facet::_S_create_c_locale name not valid