在app.json里面加入
"renderer": "skyline",
"componentFramework":"glass-easel",
"rendererOptions": {
"skyline": {
"defaultDisplayBlock":true
}
},
"lazyCodeLoading": "requiredComponents",
开发者工具和真机测试都需要开启skyline引擎
使用snapshot包裹要截图的内容
<snapshot mode="view" id="view">
<view>页面</view>
</snapshot>
dian(){
this.createSelectorQuery().select("#view")
.node().exec(res => {
const node = res[0].node
node.takeSnapshot({
type: 'arraybuffer',
format: 'png',
success: (res) => {
console.log(res,'ressss')
const f = `${wx.env.USER_DATA_PATH}/hello.png`
const fs = wx.getFileSystemManager();
fs.writeFileSync(f, res.data, 'binary')
this.setData({
img: f
})
把海报图片保存到本地
wx.saveImageToPhotosAlbum({
filePath: f
})
}
})
})
}