fix local

pull/165/head
tjz 2018-03-15 22:21:25 +08:00
parent a00e1285b1
commit aaa0267b7b
2 changed files with 13 additions and 4 deletions

View File

@ -11,12 +11,12 @@ export default {
children: PropTypes.func, children: PropTypes.func,
}, },
inject: { inject: {
antLocale: { default: {}}, localeData: { default: {}},
}, },
methods: { methods: {
getLocale () { getLocale () {
const { componentName, defaultLocale } = this const { componentName, defaultLocale } = this
const { antLocale } = this const { antLocale } = this.localeData
const localeFromContext = antLocale && antLocale[componentName] const localeFromContext = antLocale && antLocale[componentName]
return { return {
...(typeof defaultLocale === 'function' ? defaultLocale() : defaultLocale), ...(typeof defaultLocale === 'function' ? defaultLocale() : defaultLocale),
@ -25,7 +25,7 @@ export default {
}, },
getLocaleCode () { getLocaleCode () {
const { antLocale } = this const { antLocale } = this.localeData
const localeCode = antLocale && antLocale.locale const localeCode = antLocale && antLocale.locale
// Had use LocaleProvide but didn't set locale // Had use LocaleProvide but didn't set locale
if (antLocale && antLocale.exist && !localeCode) { if (antLocale && antLocale.exist && !localeCode) {

View File

@ -30,7 +30,7 @@ export default {
props: { props: {
locale: PropTypes.object.def({}), locale: PropTypes.object.def({}),
}, },
provide () { data () {
return { return {
antLocale: { antLocale: {
...this.locale, ...this.locale,
@ -38,8 +38,17 @@ export default {
}, },
} }
}, },
provide () {
return {
localeData: this.$data,
}
},
watch: { watch: {
locale (val) { locale (val) {
this.antLocale = {
...this.locale,
exist: true,
}
setMomentLocale(val) setMomentLocale(val)
}, },
}, },