0

有没有办法将单水疗道具传递给 vue i18n 实例,将其分配给消息 i18n 道具。

I18n 构造函数:

const i18n = new VueI18n({
  locale: process.env.VUE_APP_I18N_LOCALE,
  messages: {},
});

Vue单spa实例:

const vueLifecycles = singleSpaVue({
  Vue,
  appOptions: {
    el: '#account',
    render() {
      return (
        <App
          eventBus={this.$data.eventBus}
          lang={this.$data.lang}
        ></App>
      );
    },
    i18n,
  },
});

信息:我无权访问lang渲染功能之外。

基本上,我需要 i18n 消息对象中的 lang 道具。我已经尝试返回 lang,但它进入构造函数,不起作用。我还尝试在收到后重新实例化 i18n/消息,但lang也不起作用。还有其他想法吗?

4

1 回答 1

0

所以我想通了。只能通过以下方式更改已安装的 vue 实例中的消息:

this.$i18n.setLocaleMessage = newLangObj
于 2021-02-16T19:24:10.617 回答