canvas 的图为啥显示不了 base64的显示不出来
let promiseImg = new Promise(function (resolve, reject) {
wx.getImageInfo({
src: cover,
success: function (cover) {
resolve(cover.path)
console.log(cover)
}
})
})
promiseImg.then(function (cover) {
that.setData({
cover:cover
})
ctx.drawImage(cover, 0, 0, 320, 170);
})
getImageInfo返回本地的路径也显示不到canvas上如果吧路径放到img上就能显示
let that = this;
console.log(that.data.imgPath)
const ctx = wx.createCanvasContext(‘myCanvas’);
ctx.drawImage(that.data.imgPath, 0, 0, 150, 150);
ctx.draw(true, function () {
wx.canvasToTempFilePath({
x: 0,
y: 0,
width: 150,
height: 150,
destWidth: 150,
destHeight: 150,
canvasId: ‘myCanvas’,
success: function (res) {
console.log(res.tempFilePath)
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success(res) {
console.log(res)
}, fail(res) {
console.log(res)
}
})
}, fail(res) {
console.log(‘canvasToTempFilePath’, res)
}
})
});
我也是遇到同样的问题,开发工具能显示图片,保存图片,到真机就不能显示图片到画布上面了__,that.data.imgPath 是图片base64内容, 要是正常图片路径就可以显示,base64真机显示不了到画布, 我的手机机型是 小米6,微信版本6.7.2__