网络图片要先下载下来后,用得到的路径再画
如:
const ctx = wx.createCanvasContext('myCanvas');
wx.downloadFile({
url:"网路图片路径",
success:function(res){
ctx.drawImage(res.tempFilePath, 0, 0, 300, 320);//用这个路径才行
这里写第二点...
}
});
2.使用canvasToTempFilePath时要在draw的回调中写
ctx.draw(true,function(){
wx.canvasToTempFilePath(.......);
});
挪,我是这样写的
html
js
解决了没,我也有这种情况
放了
wx.canvasToTempFilePath({
x: 0,
y: 0,
width: 680,
height: 570,
destWidth: 100,
destHeight: 100,
fileType: 'png',
canvasId: 'myCanvas',
success: function (res) {
self.setData({
pic:res.tempFilePath
})
}
},this)
res.tempFilePath 返回的
你这个路径是怎么得到了啊
这个地址只有在调试工具里面打开,在浏览器和真机上面都打不开呢
http://tmp/wxfd06f21f36822922.o6zAJs0XKKf6v5cDfw3L0sR1dPV8.QN24cabiSVDK3afc749907709833c4cca2642379be11.png
返回的图片地址是这样的
你的是网络图片吗
这里配置下你图片的域名试下 ,
还是你也是那个处理图片的问题?
能不能麻烦问下,我把res.tempFilePath这个路径直接放在页面中的image的src里在真机不显示,怎么解决啊
嗯嗯