[add] EventBus使用
This commit is contained in:
41
Project/assets/Script/HelloWorld.ts
Normal file
41
Project/assets/Script/HelloWorld.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
// Learn TypeScript:
|
||||
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
|
||||
// Learn Attribute:
|
||||
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
|
||||
// Learn life-cycle callbacks:
|
||||
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
|
||||
|
||||
const { ccclass, property } = cc._decorator;
|
||||
|
||||
@ccclass
|
||||
export default class HelloWorld extends cc.Component {
|
||||
|
||||
@property(cc.Label)
|
||||
public Label: cc.Label = null;
|
||||
|
||||
@property
|
||||
public Text: string = 'hello';
|
||||
|
||||
@property(cc.Button)
|
||||
public Btn: cc.Button = null;
|
||||
|
||||
// LIFE-CYCLE CALLBACKS:
|
||||
|
||||
// protected onLoad() {}
|
||||
|
||||
public onClickBtn() {
|
||||
let url: string = window.location.search;
|
||||
let URLscheme: any[] = [];
|
||||
if (url.indexOf("?") !== -1) {
|
||||
let str = url.substring(1);
|
||||
let strs = str.split("&");
|
||||
for (let i = 0; i < strs.length; i++) {
|
||||
URLscheme[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
|
||||
}
|
||||
}
|
||||
if (URLscheme["host"]) {
|
||||
opener?.window.parent.postMessage({ data: "hello" }, URLscheme["host"]);
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Project/assets/Script/HelloWorld.ts.meta
Normal file
9
Project/assets/Script/HelloWorld.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.8",
|
||||
"uuid": "fdc7a7f1-b81c-4e03-b45f-06e57e3529a6",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
Reference in New Issue
Block a user