When canvas sets up online pictures, it prompts that the canvas is contaminated, and setting crossOrigin is cross-domain.

Local pictures are fine. Online pictures will prompt the canvas to be contaminated. If you see what they say, setting crossOrigin will prompt the picture to cross-domain.


is there any advice that has been solved?
canvas = this.mycanvas;
ctx = canvas.getContext("2d");
const img = new Image();
img.src = backgroundImg;
img.onload = function () {
    //...
}
//
//canvas.toDataURL("image/png");:
//Failed to execute "toDataURL" on "HTMLCanvasElement": Tainted canvases may not be exported.

canvas = this.mycanvas;
ctx = canvas.getContext("2d");
const img = new Image();
//img.crossOrigin = "";
// img.crossOrigin = "Anonymous"
// img.setAttribute("crossOrigin","anonymous");
img.setAttribute("crossOrigin", "Anonymous");
img.src = backgroundImg;
// img.src = "./sees.png";//
img.onload = function () {
    //...
}
//setAttribute:
//Access to image at "http://....png" from origin "http://localhost:8080" has been blocked by CORS policy: No "Access-Control-Allow-Origin" header is present on the requested resource.

img.src =. to call the last sentence, set crossOrigin before setting

something like this

  https://stackoverflow.com/que.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bd70e7-3106b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bd70e7-3106b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?