view id list

This commit is contained in:
pengfei.zhou
2019-07-24 11:43:38 +08:00
parent 9592e9ed3d
commit ac5dc091d5
12 changed files with 105 additions and 64 deletions

View File

@@ -182,7 +182,7 @@ export abstract class View implements Modeling {
}
@Property
config?: Config
layoutConfig?: Config
@Property
onClick?: Function

View File

@@ -4,11 +4,17 @@ export interface Modeling {
export function obj2Model(obj: Model): Model {
if (obj instanceof Array) {
return obj.map(e => obj2Model(e)) as Model
} else if (obj instanceof Object
&& Reflect.has(obj, 'toModel')
&& Reflect.get(obj, 'toModel') instanceof Function) {
obj = Reflect.apply(Reflect.get(obj, 'toModel'), obj, [])
return obj
} else if (obj instanceof Object) {
if (Reflect.has(obj, 'toModel') && Reflect.get(obj, 'toModel') instanceof Function) {
obj = Reflect.apply(Reflect.get(obj, 'toModel'), obj, [])
return obj
} else {
for (let key in obj) {
const val = Reflect.get(obj, key)
Reflect.set(obj, key, obj2Model(val))
}
return obj
}
} else {
return obj
}

View File

@@ -0,0 +1,11 @@
export class ViewModel<T extends Object> {
data: T
constructor(obj: T) {
this.data = new Proxy(obj, {
get: () => {
}
})
}
}