原因分析 

查看官方文档的解释

在 控制台中 过滤这个字段

过滤关键字"SecurityComponentCheckFail"可以获取具体原因。

得到 产生的原因

是 因为层叠的原因     savebutton 组件必须的  在屏幕的最高层  不能有任何的覆盖和遮挡

通过这样书写就解决了

 // 下面是安全控件
        Column(){
          SaveButton(this.SaveButtonOptions)
            .backgroundColor('#FC3F41')
            .onClick(async (event:ClickEvent, result:SaveButtonOnClickResult) => {
              if (result == SaveButtonOnClickResult.SUCCESS) {
                componentSnapshot.get("水印照片", (error: Error, pixmap: image.PixelMap) => {
                  if (error) {
                    console.log("error: " + JSON.stringify(error))
                    return;
                  }
                  //将pixelMap打包为图片格式
                  const imagePackerApi = image.createImagePacker();
                  let packOpts : image.PackingOption = { format:"image/jpeg", quality:98 };
                  // 将数据照片保存到相册中
                  saveToFile(pixmap,getContext(this))
                  imagePackerApi.packing(pixmap, packOpts).then( (data : ArrayBuffer) => {
                    // data 为打包获取到的文件流,写入文件保存即可得到一张图片
                    this.upload(data)
                  }).catch((error : BusinessError) => {
                    console.error('Failed to pack the image. And the error is: ' + error);
                  })
                })
              }
            })
        }
        .position({
          x:'68%',
          y:'77%'
        })
        .border({
          width:1,
          color:'#E60012'
        })
        .zIndex(3)

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐