欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 汽车 > 时评 > 鸿蒙开发中 SaveButton 按钮 保存按钮点击后权限授权失败。

鸿蒙开发中 SaveButton 按钮 保存按钮点击后权限授权失败。

2025/9/18 3:28:15 来源:https://blog.csdn.net/Ruiqi8/article/details/145489236  浏览:    关键词:鸿蒙开发中 SaveButton 按钮 保存按钮点击后权限授权失败。

原因分析 

查看官方文档的解释

在 控制台中 过滤这个字段

过滤关键字"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)

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词