Vue_Cocos/Project/assets/Script/HelloWorld.ts

49 lines
1.3 KiB
TypeScript
Raw Normal View History

2022-08-01 06:23:29 +00:00
// 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:
2022-08-01 09:12:37 +00:00
protected onLoad() {
let self = this;
this.Label.string = this.Text;
window["eventBus"].on('SendContent', (content: string) => {
self.Label.string = content;
})
}
2022-08-01 06:23:29 +00:00
public onClickBtn() {
2022-08-01 09:12:37 +00:00
window["eventBus"].emit("Alert", "hello");
// 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();
// }
2022-08-01 06:23:29 +00:00
}
}