import { _decorator, Node, Button } from 'cc'; import { BaseView } from 'db://assets/scripts/core/BaseView'; import { ViewManager } from 'db://assets/scripts/core/ViewManager'; const { ccclass, property } = _decorator; @ccclass('PagePKData') export class PagePKData extends BaseView { @property({ type: Node, tooltip: '返回按钮' }) backBtn: Node | null = null; onViewLoad(): void { if (this.backBtn) { this.backBtn.on(Button.EventType.CLICK, this._onBackClick, this); } } onViewShow(): void { } onViewHide(): void { } private _onBackClick(): void { ViewManager.instance.back(); } onViewDestroy(): void { if (this.backBtn) { this.backBtn.off(Button.EventType.CLICK, this._onBackClick, this); } } }