mirror of
https://github.com/Gongxh0901/kunpolibrary
synced 2025-12-05 20:29:10 +00:00
UI模块添加数据绑定装饰器
1.添加数据基类,子类自动添加代理,数据变化自动通知 2.支持同属性多装饰器
This commit is contained in:
26
demo/assets/script/UI/Data/Items/DataItem.ts
Normal file
26
demo/assets/script/UI/Data/Items/DataItem.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2025-08-30
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
|
||||
import { Level } from "../../../Data/global/Level";
|
||||
import { fgui, kunpo } from "../../../header";
|
||||
const { uiheader, uiprop, uicom, uiclick } = kunpo._uidecorator;
|
||||
const { bindMethod, bindProp } = kunpo.data;
|
||||
|
||||
@uicom("Data", "DataItem")
|
||||
export class DataItem extends fgui.GComponent {
|
||||
@uiprop
|
||||
@bindProp(Level, data => data.levelid, (item: fgui.GTextField, value: number, data: Level) => {
|
||||
item.text = `关卡回调\n关卡:${value}\n层数:${data.storey}`;
|
||||
})
|
||||
@bindProp(Level, data => data.storey, (item: fgui.GTextField, value: number, data: Level) => {
|
||||
item.text = `层数回调\n关卡:${data.levelid}\n层数:${value}`;
|
||||
})
|
||||
private lab_level: fgui.GTextField;
|
||||
|
||||
public onInit(): void {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user