From a03a8408be4361e510497793a9b39caaeafe80e0 Mon Sep 17 00:00:00 2001 From: donggang <> Date: Thu, 29 Feb 2024 10:12:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/core/gui/layer/LayerNotify.ts | 2 +- assets/core/gui/prompt/CommonPrompt.ts | 6 ++++-- assets/module/common/GameComponent.ts | 8 +++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/assets/core/gui/layer/LayerNotify.ts b/assets/core/gui/layer/LayerNotify.ts index 1215dea..ddf0589 100644 --- a/assets/core/gui/layer/LayerNotify.ts +++ b/assets/core/gui/layer/LayerNotify.ts @@ -54,7 +54,7 @@ export class LayerNotify extends Node { } /** - * 显示toast + * 渐隐飘过提示 * @param content 文本表示 * @param useI18n 是否使用多语言 */ diff --git a/assets/core/gui/prompt/CommonPrompt.ts b/assets/core/gui/prompt/CommonPrompt.ts index ec3fd1c..80e8b80 100644 --- a/assets/core/gui/prompt/CommonPrompt.ts +++ b/assets/core/gui/prompt/CommonPrompt.ts @@ -74,8 +74,10 @@ export class CommonPrompt extends Component { } private setBtnCancelLabel() { - this.lab_cancel!.dataID = this.config.cancelWord; - this.lab_cancel!.node!.parent!.active = this.config.needCancel || false; + if (this.lab_cancel) { + this.lab_cancel.dataID = this.config.cancelWord; + this.lab_cancel.node.parent!.active = this.config.needCancel || false; + } } private onOk() { diff --git a/assets/module/common/GameComponent.ts b/assets/module/common/GameComponent.ts index 96a8704..321037e 100644 --- a/assets/module/common/GameComponent.ts +++ b/assets/module/common/GameComponent.ts @@ -234,7 +234,8 @@ export class GameComponent extends Component { */ protected setButton(...args: string[]) { this.node.on(Node.EventType.TOUCH_END, (event: EventTouch) => { - var func = this[event.target.name]; + var self: any = this; + var func = self[event.target.name]; if (func) func(event); else @@ -251,10 +252,11 @@ export class GameComponent extends Component { * onGlobal(event: string, args: any) { console.log(args) }; */ protected setEvent(...args: string[]) { + var self: any = this; for (const name of args) { - var func = this[name]; + var func = self[name]; if (func) - this.on(name, this[name], this); + this.on(name, self[name], this); else console.error(`名为【${name}】的全局事方法不存在`); }