通过onBackPress事件拦截,返回true表示页面自己处理返回逻辑@Entry @Component struct IndexComponent { @State textColor: Color = Color.Black; onPageShow() { this.textColor = Color.Blue; console.info('IndexComponent onPageShow'); } onPageHide() { this.textColor = Color.Transparent; console.info('IndexComponent onPageHide'); } onBackPress() { this.textColor = Color.Red; console.info('IndexComponent onBackPress'); return true } build() { Column() { Text('Hello World') .fontColor(this.textColor) .fontSize(30) .margin(30) }.width('100%') } }参考链接https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-custom-component-lifecycle-V5\#onbackpress
通过onBackPress事件拦截,返回true表示页面自己处理返回逻辑
参考链接https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-custom-component-lifecycle-V5\#onbackpress