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

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

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