小程序
小游戏
企业微信
微信支付
扫描小程序码分享
https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.canvasToTempFilePath.html
3 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
wxml没看到呢?wxml里面没写canvas-id="share" 写到id里面去了吗?
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
canvas-id="share"
const ctx = wx.createCanvasContext('share', that)
const that = this;
setTimeout(()=>{
wx.canvasToTempFilePath({
x: 0,
y: 0,
width: 332,
height: 360,
destWidth: 332 / 2,
destHeight: 360 / 2,
canvasId: 'share',
success(res){
console.log(res)
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success(result){
console.log(result);
wx.showToast({
title: '证件已保存至相册',
icon: 'none'
})
},
fail(err){
console.log(err)
}
}, that)
}, 500)
创建上下文和保存的时候都传入了this,但还报错找不到
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
wxml没看到呢?wxml里面没写canvas-id="share" 写到id里面去了吗?
canvas-id="share"
不客气,这是我应该做的~能帮到你是我的荣幸!如果觉得有帮助的话请在顶部回复里点个有用。让其他人碰到同类问题时少走弯路~
const ctx = wx.createCanvasContext('share', that)
const that = this;
setTimeout(()=>{
wx.canvasToTempFilePath({
x: 0,
y: 0,
width: 332,
height: 360,
destWidth: 332 / 2,
destHeight: 360 / 2,
canvasId: 'share',
success(res){
console.log(res)
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success(result){
console.log(result);
wx.showToast({
title: '证件已保存至相册',
icon: 'none'
})
},
fail(err){
console.log(err)
}
})
},
fail(err){
console.log(err)
}
}, that)
}, 500)
创建上下文和保存的时候都传入了this,但还报错找不到