A页面
 

  // 存储返回路径,以便水印使用后能返回到当前页面
   AppStorage.setOrCreate('watermarkReturnPath', 'ImageRemoveWatermark');
   this.pathStack.pushPathByName('B',null,false)

B页面(正常跳)

  // 跳转到水印详情页
                    this.pathStack.pushPath({
                      name: 'C',
                      param: item
                    });

C页面

 @StorageLink('watermarkReturnPath') returnPath: string = '';


// 功能方法
private btnOnclick(){
     // 4. 检查是否有指定的返回路径
        if (this.returnPath) {
          // 返回到指定页面
          this.pageStack.popToName(this.returnPath);
          // 清空返回路径
          AppStorage.Delete('watermarkReturnPath');
        } else {
          // 默认返回上一页
          this.pageStack.pop();
        }
}

Logo

讨论HarmonyOS开发技术,专注于API与组件、DevEco Studio、测试、元服务和应用上架分发等。

更多推荐