参考:http://kazupon.github.io/vue-i18n/zh/introduction.html
npm install vue-i18n

在main.ts中

//多语言切换
import VueI18n from 'vue-i18n'
Vue.use(VueI18n)
const i18n = new VueI18n({
    locale: 'zh', // 语言标识
    messages: {
        'zh': require('./assets/lang/zh'),
        'en': require('./assets/lang/en')
    }
})

new Vue({
i18n,
router,
store,
render: h => h(App)
}).$mount('#app')

国际化

建立zh.js和en.js内容如下即可
module.exports = { lang:[ {label:"Chinese",value:"zh"}, {label:"English",value:"en"} ], home: { title: "The more you know, the more you win" }, content: { main: "这里是内容" } }

使用

<p class="big_title">{{$t('home.title')}}</p>

js中使用 this.$t('home.title')}

相关文章:

  • 2021-05-22
  • 2021-12-04
  • 2021-07-18
  • 2022-01-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-06
  • 2021-12-26
  • 2022-12-23
  • 2021-07-20
  • 2022-12-23
  • 2022-12-23
  • 2021-12-24
相关资源
相似解决方案