测试环境Laya 1.6
1、使用Laya分别创建2个工程,一个为主域工程,一个为子域工程
import WebGL = Laya.WebGL;
// 程序入口
class GameMain{
constructor()
{
Laya.MiniAdpter.init(true,false);
Laya.init(720,1280);
this.onloaded();
}
private onloaded(){
console.log("主域加载完成");
if(Laya.Browser.onWeiXin){
var open = wx.getOpenDataContext();
open.postMessage("hello");
console.log("主域发送信息成功");
}
}
}
new GameMain();
import WebGL = Laya.WebGL;
// 程序入口-子域
class GameMain{
constructor()
{
Laya.MiniAdpter.init(true,true);
Laya.init(720,1280);
this.onloaded();
}
private onloaded(){
console.log("子域加载完成");
wx.OnMessage(function(data){
console.log("我是子域,接受主域来的信息" + data);
})
}
}
let gameMain = new GameMain();
2、子域工程发布后将文件夹中的code.js
、game.js
、wea