1. 首先,再次被網上一大堆屎一樣的資料搞得浪費了我一天時間。各種坑。
2. 本文先講一種正確的方式,然后再列舉坑。
去www.egret.com下載最新的引擎,我的最新版本是5.2.2. 然后就會被安裝了一個全家桶。在里面,你還要在去點擊Egret Wing,安裝個開發環境。

然后,在項目的地方,新建一個游戲項目,帶EUI框架:

必須注意紅框的地方,避免踩坑。類型是Egret游戲項目。之后,全家桶就會默認打開Egret Wing進入開發環境。

在src目錄下面,新建模板文件——新建EUI組件。

這個時候,第一個坑出現,沒有default.thm.json文件。
自己new一個,里面填寫{}, 放在resource目錄下:

之后再新建EUI組件就沒有報錯了。

我新建一個叫做Helloworld的組件。

時候就會在resource/eui_skins目錄下,出現了exml窗體界面文件,點擊,添加一個label,名字是nameL

之后,在src目錄下,修改Hellworld.js文件:
class Helloworld extends eui.Component implements  eui.UIComponent {
	public nameL : eui.Label;
	public constructor() {
		super();
		this.addEventListener(eui.UIEvent.COMPLETE, this.onComplete, this);
	}
	protected partAdded(partName:string,instance:any):void
	{
		super.partAdded(partName,instance);
	}
	protected childrenCreated():void
	{
		super.childrenCreated();
	}
	protected onComplete(e):void{
		this.nameL.addEventListener(egret.TouchEvent.TOUCH_TAP, this.tap, this);
	}
	protected tap(e):void{
		this.nameL.text = "HELLO WORLD";
	}
	
}
 
        注意這里面的坑一大堆。
1. 首先,不需要指定this.SkinName,否則微信小游戲會一大堆搓。
2. 要在構造函數監聽onComplete時間,然后里面去綁定nameL的監聽器。忘記什么childCreated之類的,都是坑。
最后,在Main.js的入口函數里面,:createGameScene方法,把EUI添加到舞台:

接下來跑一下,看看效果:

恩。很好,完全沒有效果。因為沒有加EUI的主題自動映射起,接下來,我又創建了一個EUI項目,和這個游戲項目對比來開發,差別點包括:
1. manifest.json文件,game下面添加
"bin-debug/AssetAdapter.js",
"bin-debug/ThemeAdapter.js"
2. egretProperties.json,添加eui節點:
 "eui": {
 "exmlRoot": [
 "resource/eui_skins"
 ],
 "themes": [
 "resource/default.thm.json"
 ],
 "exmlPublishPolicy": "commonjs"
 }, 
3. src目錄,添加AssetAdapter,ThemeAdapter
4. Main.ts,在onAddToStage方法,添加
 //inject the custom material parser
 //注入自定義的素材解析器
 let assetAdapter = new AssetAdapter();
 egret.registerImplementation("eui.IAssetAdapter", assetAdapter);
 egret.registerImplementation("eui.IThemeAdapter", new ThemeAdapter());
5. Main.ts, 在loadResource添加:
await this.loadTheme();
 private loadTheme() {
 return new Promise((resolve, reject) => {
 // load skin theme configuration file, you can manually modify the file. And replace the default skin.
 //加載皮膚主題配置文件,可以手動修改這個文件。替換默認皮膚。
 let theme = new eui.Theme("resource/default.thm.json", this.stage);
 theme.addEventListener(eui.UIEvent.COMPLETE, () => {
 resolve();
 }, this);
 })
 }
然后在跑一下,就出現了。
最后點擊發布,微信小游戲。然后打開微信的開發工具,加載導出的項目目錄。全部完成!!!!
這里就在游戲項目里面成功的引入了EUI皮膚管理!
其他的一些坑再度強調:
1. EUI的類,不需要聲明skinName!!! 否則比錯
2. 沒有XML的讀取,因為使用了commonjs方式把皮膚編譯成js了。如果你要xml去夾在,必錯!
3. 沒有什么window.DOMParser = require("./xmldom/xmldom.js").DOMParser;
那個智障的egret官方微信小游戲FAQ,直接忽略到,簡直就是把你往坑再踩一腳。
http://developer.egret.com/cn/github/egret-docs/Engine2D/minigame/minigameFAQ/index.html
