view id list
This commit is contained in:
@@ -23,6 +23,11 @@ export class MyPage extends Panel {
|
||||
state.set(state.get() + 1)
|
||||
}
|
||||
click.top = numberView.bottom + 20
|
||||
|
||||
click.layoutConfig = {
|
||||
alignment: new Gravity().centerX()
|
||||
}
|
||||
|
||||
rootView.addChild(click)
|
||||
|
||||
const vlayout = new VLayout
|
||||
|
@@ -182,7 +182,7 @@ export abstract class View implements Modeling {
|
||||
}
|
||||
|
||||
@Property
|
||||
config?: Config
|
||||
layoutConfig?: Config
|
||||
|
||||
@Property
|
||||
onClick?: Function
|
||||
|
@@ -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
|
||||
}
|
||||
|
11
js-framework/src/vm/viewmodel.ts
Normal file
11
js-framework/src/vm/viewmodel.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export class ViewModel<T extends Object> {
|
||||
data: T
|
||||
constructor(obj: T) {
|
||||
this.data = new Proxy(obj, {
|
||||
get: () => {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user