收藏
回答

使用skyline生成的海报无法下载?

在某一个页面使用skyline下载海报时,开发工具提示takeSnapshot:fail webview renderer is not supporte,需要我将小程序的线上最低基础库改成2.29.2才能下载吗?

page.json的代码为:"navigationBarTitleText""详情",
  "usingComponents": {},
  "renderer""skyline",
  "navigationStyle":"custom",
  "componentFramework":"glass-easel"

app.json的部分代码为:

  "lazyCodeLoading""requiredComponents",
  "rendererOptions": {
    "skyline": {
      "defaultDisplayBlock"true,
      "defaultContentBox"true
    }
  }

page.js下载海报的代码为:

this.createSelectorQuery().select("#view")
      .node().exec(res => {
        const node = res[0].node
        node.takeSnapshot({
          // type: 'file' 且 format: 'png' 时,可直接导出成临时文件
          type'arraybuffer',
          format: 'png',
          success: (res) => {
            console.log(123)
            const f = `${wx.env.USER_DATA_PATH}/hello.png`
            const fs = wx.getFileSystemManager();
            fs.writeFileSync(f, res.data, 'binary')
            wx.showToast({
              title: '保存成功'
            })


            wx.saveImageToPhotosAlbum({
              filePath: f,
              success() {
                wx.showToast({
                  title: '已保存到相册',
                  icon: 'success',
                  duration: 2000
                })
              },
              fail(err) {
                if (err.errMsg === "saveImageToPhotosAlbum:fail auth deny") {
                  that.secondGetPhoteAuthor();
                } else {
                  showToast("您已拒绝授权相册权限,请截屏保存分享");
                }
              },
              complete() {
                wx.hideLoading()
              }
            })
          },
          fail(res) {
            console.log("takeSnapshot fail:", res)
            wx.hideLoading()
          }
        })
      })
回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容