fix: setting language does not work in src/config/config.js; 🌟

master
iczer 4 years ago
parent 9425bcb1f9
commit 36e9e0a9f0
  1. 33
      src/App.vue

@ -5,7 +5,6 @@
</template>
<script>
import zh_CN from 'ant-design-vue/es/locale-provider/zh_CN'
import enquireScreen from './utils/device'
import {mapState} from 'vuex'
@ -13,11 +12,12 @@ export default {
name: 'App',
data() {
return {
locale: zh_CN
locale: {}
}
},
created () {
let _this = this
this.setLanguage(this.lang)
enquireScreen(isMobile => {
_this.$store.commit('setting/setDevice', isMobile)
})
@ -30,19 +30,7 @@ export default {
this.setWeekModeTheme(val)
},
lang(val) {
this.$i18n.locale = val
switch (val) {
case 'CN':
this.locale = require('ant-design-vue/es/locale-provider/zh_CN').default
break
case 'HK':
this.locale = require('ant-design-vue/es/locale-provider/zh_TW').default
break
case 'US':
default:
this.locale = require('ant-design-vue/es/locale-provider/en_US').default
break
}
this.setLanguage(val)
}
},
computed: {
@ -55,6 +43,21 @@ export default {
} else {
document.body.classList.remove('week-mode')
}
},
setLanguage(lang) {
this.$i18n.locale = lang
switch (lang) {
case 'CN':
this.locale = require('ant-design-vue/es/locale-provider/zh_CN').default
break
case 'HK':
this.locale = require('ant-design-vue/es/locale-provider/zh_TW').default
break
case 'US':
default:
this.locale = require('ant-design-vue/es/locale-provider/en_US').default
break
}
}
}
}

Loading…
Cancel
Save