首页 > 其他 > 详细

vue 国际化二

时间:2020-01-01 13:01:42      阅读:86      评论:0      收藏:0      [点我收藏+]
参考: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‘)}

vue 国际化二

原文:https://www.cnblogs.com/mary-123/p/12128589.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!