安装方法
1.使用CDN直接引用
<script src="https://unpkg.com/vue/dist/vue.js"></script> <script src="https://unpkg.com/vue-i18n/dist/vue-i18n.js"></script>
2.NPM
$ npm install vue-i18n
3.Yarn
$ yarn add vue-i18n
使用方法
在这里只介绍vue的使用方法
<script>
/* 国际化使用规则 */
import Vue from 'vue'
import VueI18n from 'vue-i18n'
Vue.use(VueI18n)
const messages = {
en: {
message: {
hello: 'world hello'
}
},
zh: {
message: {
hello: '世界'
}
}
}
const i18n = new VueI18n({
locale: 'zh',
messages
})
export default {
data () {
return {
hello: this.$t('message.hello')
}
},
i18n
}
</script><div id="#app">
<p>{{ $t("message.hello") }}</p>
</div>vue-i18n插件使用参考文档
http://kazupon.github.io/vue-i18n/en/
来源:http://blog.csdn.net/lyqhn2012/article/details/73480256
声明:本站所有文章和图片,如无特殊说明,均为原创发布,转载请注明出处。