fix: bug fix

This commit is contained in:
0xJacky 2022-09-23 23:06:41 +08:00
parent 5e89860068
commit 20daf836e9
No known key found for this signature in database
GPG key ID: B6E4A6E4A561BAF0
4 changed files with 55 additions and 15 deletions

View file

@ -22,8 +22,27 @@ interface IEdit {
generate: boolean
}
function fn(obj: Object, desc: any) {
let arr: string[]
if (typeof desc === 'string') {
arr = desc.split('.')
} else {
arr = [...desc]
}
while (arr.length) {
// @ts-ignore
const top = obj[arr.shift()]
if (top === undefined) {
return null
}
obj = top
}
return obj
}
function readonly(edit: IEdit, dataSource: any, dataIndex: any) {
return h('p', dataSource[dataIndex])
return h('p', fn(dataSource, dataIndex))
}
function input(edit: IEdit, dataSource: any, dataIndex: any) {