使用snapshot组件,发布上线后,截屏或写入文件失败是什么原因?
this.createSelectorQuery() .select("#snapshot") .node() .exec(res => { const node = res[0].node node.takeSnapshot({ type: 'arraybuffer', format: 'png', success: (res) => { const f = `${wx.env.USER_DATA_PATH}/poster.png` const fs = wx.getFileSystemManager(); // 将海报数据写入本地文件 fs.writeFileSync(f, res.data, 'binary') this.saveImageToPhotosAlbum(f) }, fail: (res) => { console.log('截图错误:', res.errMsg) wx.showToast({ title: '海报生成失败~', icon: 'loading', duration: 1000 }); }, complete: () => { this.setData({ showServiceCode: false }) wx.hideLoading() } }) })