Canvas报错: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data.
let bgImage = new Image() bgImage.src = this.currentUrl bgImage.onload = () => { this.canvasObj.drawImage(bgImage, 0, 0, this.canvas.width, this.canvas.height) this.bgData.push(this.canvasObj.getImageData(0, 0, 1000, 400))
}
//this.currentUrl 是服务器图片地址
在向canvas添加服务器上的图片时候报跨域的错误
解决办法:添加如下代码解决跨域问题
bgImage.crossOrigin = ''