Egret之微信小游戏基础Bug修复
一 : 第三方类库未定义
如 : smallLib类库
解决方案:
找到wxgame.ts , 在onFile方法中加入
if(filename=="libs/modules/smallLib/smallLib.js"||filename=="libs/modules/smallLib/smallLib.min.js"){content+=";window.smallLib=smallLib;"}
二:第二加载问题
使用URLLoader 或 HttpRequest加载包内资源,都不会成功 , so
1 , 在default_res.json中配置文件
2,Main.ts 加载
//微信特殊的加载方案if(egret.Capabilities.runtimeType==egret.RuntimeType.WXGAME){awaitRES.loadGroup("config",1,null);awaitRES.getResAsync("common_xml").then($value=>{console.log(`微信加载配置方案成功:${$value}`);common.XmlCommonConfigManager.Instance.root=egret.XML.parse(<string>$value);},$error=>{console.log("微信加载配置方案错误");});}//--------if(egret.Capabilities.runtimeType==egret.RuntimeType.WXGAME){awaitRES.loadGroup("config",1,null);common.XmlCommonConfigManager.Instance.root=egret.XML.parse(RES.getRes("common_xml"));//awaitRES.getResAsync("common_xml").then(//$value=>{//common.XmlCommonConfigManager.Instance.root=egret.XML.parse(<string>$value);//},//$error=>{//}//);}
三:xml问题
1,使用xmldom.zip包(附件提供)
2,解压放入到微信项目的根目录
3,找到game.js , 在"egret.runEgret"上加入 window.DOMParser = require("./xmldom/xmldom.js").DOMParser;
四:自定义皮肤的问题
需要暴露类
错误:
代码:
modulecommon{/***通用面板皮肤*@authorHusz*/exportclassCommonPanelextendseui.Componentimplementseui.UIComponent{}if(egret.Capabilities.runtimeType==egret.RuntimeType.WXGAME){window["CommonPanel"]=CommonPanel;}}
正确:
附上 : 通用皮肤设置 -> xmlns:common="*"
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。