1, the installation
npm install vue-i18n
2、import
import VueI18n from 'vue-i18n'
3, Mount
Vue.use (VueI18n)
4, create an instance
const vuei18n = new VueI18n({ locale: 'zh', messages: { 'zh': require('./static/lang/zh'), 'en': require('./static/lang/en') } })
5, an example corresponding to the language pack
ZH = const Export { name: 'Bob' , type: 'beautiful girl' }
export const en = { name: 'Bob', type: 'Pretty girl' }
6, bound to the template
<Span> {{$ t ( 'someThing')}} </ span> someThing // here is the variable name
7, the handover process vue in English
this.$vuei18n.locale = 'en'