Laya發布模式區分
- 2019 年 12 月 11 日
- 筆記
1內嵌模式
該模式導出時會將頁面的配置資訊導出為項目程式碼文件
export class RuntimeTestUI extends Scene { public static uiView:any ={"type":"Scene","props":{"width":640,"height":1136},"compId":2,"child":[{"type":"Image","props":{"y":0,"x":0,"width":206,"skin":"comp/image.png","name":"Image_Bg","height":170},"compId":5}],"loadList":["comp/image.png"],"loadList3D":[]}; constructor(){ super()} createChildren():void { super.createChildren(); this.createView(RuntimeTestUI.uiView); } }
2載入模式
會將所有頁面的配置資訊導出為json格式的一個文件
export class RuntimeTestUI extends Scene { constructor(){ super()} createChildren():void { super.createChildren(); this.loadScene("demo1/RuntimeTest"); } }
3分離模式
將UI介面上所有組件的屬性、介面布局等邏輯與介面內容分離開,分離模式也是導出為json格式,但有所區別的是分離模式會將每一個頁面獨立導出,會產生多個json文件。
4文件模式
不生成場景類,進一步減少文件大小,使用的時候用Scene.load方式載入。區別於前三種最大的的不同就是,文件模式不能直接調用場景內的變數,需要getchild獲取之後進行操作。前三種的場景類里聲明了變數,有程式碼提示直接可以操作內部的變數。