亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

vue中i18n如何做多語言切換

vue中i18n如何做多語言切換

花開花落_青藤 2017-08-10 18:06:25
main.js中我寫了幾個不同的語言Vue.use(VueI18n)const messages = {en: {message: {hello: 'world hello'}},zh: {message: {hello: '世界'}},de:{message:{hello:'Die Welt'}},ko:{message:{hello:'??'}}}const i18n = new VueI18n({locale: 'ko',messages})new Vue({i18n ,el: '#app',router,template: '<App/>',components: { App }})在組件中<button type="button" @click="changeLanguage('en')">英文</button><script>export default {data () {return {hello: this.$t('message.hello'),}},methods:{changeLanguage(value){if(value=='en'){this.$locale='en'}}}}</script>我想做個點擊事件實現點擊切換語言,但是沒有思路。我一直想著如何把組件中拿到的locale傳到main.js中去改變語言顯示。思路是否有問題呢,也不知道如何傳過去。。。
查看完整描述

4 回答

?
kkkkkkkll

TA貢獻1條經驗 獲得超0個贊

同問???

查看完整回答
反對 回復 2017-10-19
?
慕斯8308057

TA貢獻2條經驗 獲得超0個贊

同樓上

查看完整回答
反對 回復 2017-10-18
?
ExceptionMa

TA貢獻1條經驗 獲得超0個贊

你實現了嗎?

查看完整回答
反對 回復 2017-09-26
  • 4 回答
  • 0 關注
  • 6741 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號