正常情况多个img的onload都会执行,并绘制在canvas中,但是代码片段的3个图片就第一个正常打印和绘制;微信版本小程序是正常的,已经修复,是不是企业版本小程序的没有同步修复此问题!!!!
// 图片一
const img1 = canvas.createImage()
img1.onload = () => {
console.log('image加载1')
ctx.drawImage(img1, 0, 0, 212 * pixelRatio, 252 * pixelRatio);
}
img1.src =
'https://04imgmini.eastday.com/mobile/20200221/20200221145849_ec140e3a1e41ed934380fce0f7812e33_1.jpeg'
// 图片二
const img2 = canvas.createImage()
img2.onload = () => {
console.log('image加载2')
ctx.drawImage(img2, 0, 252 * pixelRatio, 212 * pixelRatio, 252 * pixelRatio);
}
img2.onerror = (res) => {
console.log('图片二加载失败',res)
}
img2.src = 'https://04imgmini.eastday.com/mobile/20200221/20200221145849_ec140e3a1e41ed934380fce0f7812e33_1.jpeg'
// 图片三
const img3 = canvas.createImage()
img3.onload = () => {
console.log('image加载3')
ctx.drawImage(img3, 0, 500 * pixelRatio, 212 * pixelRatio, 252 * pixelRatio);
}
img3.onerror = (res) => {
console.log('图片三加载失败',res)
}
img3.src = 'https://04imgmini.eastday.com/mobile/20200221/20200221145849_ec140e3a1e41ed934380fce0f7812e33_1.jpeg'
无人问津