function drawImage(sx,sy,imgW,imgH) { canvas = document.querySelector("#big_img .swiper-slide-active canvas"); canvas.width= bigSwiper.width; canvas.height = bigSwiper.width; var context =canvas.getContext('2d'); img.src = canvas.dataset.src; img.onload = function(){ context.clearRect(0, 0, canvas.width, canvas.height); context.drawImage(img,sx,sy,img.naturalWidth,img.naturalHeight,0,0,imgW,imgH); } } $(function(){ drawImage(0,0,100,100)//当sx和sy为0时画布能正常显示图片 drawImage(10,10,100,100)//当sx和sy为10时画布就不能显示图片了,这是为什么?PS:#big_img .swiper-slide-active canvas的这个画布是jQuery动态创建的,并且能成功querySelector到该画布 })
你好,我也遇到了这个问题,安卓好使,IOS有问题。请问,你的这个问题解决了吗?