标签:lower erlang efault hello pre case cas temp sage
1、下载安装
npm install vue-i18n --save
2、在src下创立文件夹language
language 下放两js
en.js
export default {
message: {
hello: ‘hello‘
}
}
zh.js
export default {
message: {
hello: ‘你好‘
}
}
3、在main.js引入
import VueI18n from ‘vue-i18n‘
import en from ‘./language/en‘
import zh from ‘./language/zh‘
Vue.use(VueI18n)
const i18n = new VueI18n({
locale: (navigator.language || navigator.browserLanguage).toLowerCase(),
messages: {
‘zh-cn‘: zh,
‘en‘: en
}
})
new Vue({
el: ‘#app‘,
router,
store,
i18n,
components: { App },
template: ‘<App/>‘,
})
4、组件中用
{{$t(‘message.hello‘)}}
标签:lower erlang efault hello pre case cas temp sage
原文地址:https://www.cnblogs.com/luckyShuang/p/11722853.html