- 当前 Bug 的表现(可附上截图)
获取不到图片
- 预期表现
获取到相对路径的图片
- 提供一个最简复现 Demo
js:
onLoad: function (options) {
var myCanvasWidth = 0;
var myCanvasHeight = 0;
wx.getSystemInfo({
success: function (res) {
myCanvasWidth = res.windowWidth
myCanvasHeight = res.windowHeight
},
})
this.setData({
canvasWidth: myCanvasWidth,
canvasHeight: myCanvasHeight
})
const ctx = wx.createCanvasContext(‘shareCanvas’)
wx.getImageInfo({
src: ‘blue.png’,
success:function(res){
// ctx.drawImage("…/…/"+res.path, 0, 0, myCanvasWidth, myCanvasHeight);
// ctx.stroke();
// ctx.draw();
console.log(res);
},fail:function(res){
console.log(res);
}
})
}
wxml:
<canvas class=‘canvasInfo’ canvas-id=“shareCanvas” style=‘width:{{canvasWidth}}px; height:{{canvasHeight}}px;’ bindlongtap=“createNewImg”>
</canvas>
个人测试结果:
iPhone8p、荣耀9、三星s9+ 测试均可获取到该图片资源
小米5、iPhone5(也可能是iPhone SE)获取不到