在main.js中引入vue-i18n并挂在到vue实例上
// 国际化
import i18n from "@/lang/index";
import locale from 'element-ui/lib/locale/lang/en'
Vue.use(ElementUI,{locale});
new Vue({
router,
store,
i18n,
render: h => h(App)
}).$mount("#app");
在页面中使用示例如下
(1)在标签内作为正文内容
<div class="title">{
{$t('menu.home')}}</div>
(2)作为标签属性使用
<input :placeholder="$t('content.main')" type="text">
切换语言
<el-dropdown szie="mini" class="changeLang" @command="handleCommand">
<span>
切换语言<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown" >
<el-dropdown-item co