#鸿蒙通关秘籍#在next开发中如何实现组件截图?因为我想实现一个类似保存当前页面的功能,所以需要相关的代码来实现的

HarmonyOS
2024-12-06 14:58:40
114浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
紫陌红尘MVT
@Builder
RandomBuilder() {
    Row() {
        QRCode(`this.message`)
        .width(200)
        .height(200)
    }
    .padding(15)
    .backgroundColor(`this.defaultColor.shape`)
    .width(230)
    .id("builder")
}

Button("组件截图")
.onClick(() => {
    componentSnapshot.createFromBuilder(()=>{this.RandomBuilder()},
    (error: Error, pixmap: image.PixelMap) => {
        if(error){
            console.log("error: " + JSON.stringify(error))
            return;
        }
        this.pixmap = pixmap
        let info = this.getUIContext().getComponentUtils().getRectangleById("builder")
    }, 320, true, {scale : 2, waitUntilRenderFinished : true})
})
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
分享
微博
QQ
微信
回复
2024-12-06 16:23:46


相关问题
鸿蒙截图功能实现问题
11197浏览 • 1回复 待解决