snapshot组件在体验版本时能正常下载海报,正式上线后显示保存图片成功,但是实际上没有下载图片?
问题如上。 <snapshot id="view" class="intro">
<view class="snapshot-box">
<view class="pages"> </view>
</view>
</snapshot>
tap() {
// Ensure all elements are rendered before taking a snapshot
setTimeout(() => {
this.createSelectorQuery().select("#view")
.node().exec(res => {
const node = res[0].node;
node.takeSnapshot({
type: 'arraybuffer',
format: 'png',
success: (res) => {
const f = `${wx.env.USER_DATA_PATH}/snapshot.png`;
const fs = wx.getFileSystemManager();
fs.writeFileSync(f, res.data, 'binary');
wx.showToast({
title: '保存成功'
});
wx.saveImageToPhotosAlbum({
filePath: f,
complete: (res) => {
console.log("saveImageToPhotosAlbum:", res);
}
});
},
fail: (res) => {
console.log("takeSnapshot fail:", res);
}
});
});
}, 500); // Delay to ensure rendering is complete
}
});