安裝方法
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>/* 國(guó)際化使用規(guī)則 */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>HTML
<div id="#app"> <p>{{ $t("message.hello") }}</p></div>vue-i18n插件使用參考文檔
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持錯(cuò)新站長(zhǎng)站。
新聞熱點(diǎn)
疑難解答
圖片精選