-
Creator 版本:3.6.1
-
目标平台: 谷歌浏览器,
-
重现方式:自己做一个了 弹出框预制,打开后一直报错
import { _decorator, Component, Node, Tween, Label, Input, EventTouch, Prefab, resources, instantiate, find } from ‘cc’;
const { ccclass, property } = _decorator;
var Alert = {
_alert: null, // prefab
_detailLabel: null, // 内容
_returnButton: null, // 返回按钮
_againButton: null, // 再来一次按钮
};
@ccclass(‘alert’)
export class alert extends Component {
static show(detailString, callBack=null) {
// 回调函数无法访问this
var self = this;
// 判断
if (Alert._alert != undefined) return;
resources.load("alert", Prefab, function (error, prefab) {
console.log(error)
if (error!=undefined) {
// cc.error(error);
return;
}
var alert = instantiate(prefab);
console.log(alert)
Alert._alert = alert;
Alert._detailLabel = find("Layout/Layout1/alert-content", alert).getComponent(Label);
Alert._returnButton = find("Layout/Layout2/LayoutL/alert-button-l", alert);
Alert._againButton = find("Layout/Layout2/LayoutR/alert-button-r", alert);
Alert._detailLabel.string = detailString;
// 添加点击事件
// console.log(Alert._detailLabel,Alert._againButton)
Alert._againButton.on('click', (event) => {
//The event is a custom event, you could get the Button component via first argument
console.log("再来一次 按钮");
// var button = event.detail;
self.onDestory();
// 加载场景
find("globalDataNode").getComponent("global").goRuning();
},self)
Alert._returnButton.on('click', (event) => {
//The event is a custom event, you could get the Button component via first argument
console.log("返回 按钮");
// var button = event.detail;
// 场景切换
self.onDestory();
find("globalDataNode").getComponent("global").goRank();
},self)
// 父视图
Alert._alert.parent = find("Canvas");
});
// 销毁 alert
self.onDestory = function () {
Alert._alert.destroy();
Alert._alert = null;
Alert._detailLabel = null;
Alert._returnButton = null;
Alert._againButton = null;
};
}
onLoad(){
}
}
- 首个报错:cocos [Scene] Buffer binding ‘CCLocal’ at set 2 binding 0 is not bounded

