2
0
mirror of https://github.com/tenrok/vue2-datepicker.git synced 2026-06-07 18:12:27 +03:00

fix: 默认语言,修复测试

This commit is contained in:
mxie
2018-06-19 14:28:16 +08:00
parent 0b424e60cd
commit 62dc6a7a2e
2 changed files with 17 additions and 19 deletions
+16 -14
View File
@@ -1,3 +1,6 @@
import Languages from '@/locale/languages'
const defaultLang = Languages.zh
export default {
methods: {
@@ -10,21 +13,20 @@ export default {
name = component.$options.name
}
}
if (component && component.language) {
const arr = path.split('.')
let current = component.language
let value
for (let i = 0, len = arr.length; i < len; i++) {
const prop = arr[i]
value = current[prop]
if (i === len - 1) {
return value
}
if (!value) {
return ''
}
current = value
const lang = component && component.language || defaultLang
const arr = path.split('.')
let current = lang
let value
for (let i = 0, len = arr.length; i < len; i++) {
const prop = arr[i]
value = current[prop]
if (i === len - 1) {
return value
}
if (!value) {
return ''
}
current = value
}
return ''
}