mirror of
				https://github.com/Gongxh0901/kunpolibrary
				synced 2025-10-31 19:35:45 +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 { | ||||
|     } | ||||
| } | ||||
							
								
								
									
										9
									
								
								demo/assets/script/UI/Data/Items/DataItem.ts.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								demo/assets/script/UI/Data/Items/DataItem.ts.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| { | ||||
|   "ver": "4.0.24", | ||||
|   "importer": "typescript", | ||||
|   "imported": true, | ||||
|   "uuid": "8eacd9e1-5ee5-4b18-9e66-4f7e70787268", | ||||
|   "files": [], | ||||
|   "subMetas": {}, | ||||
|   "userData": {} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user