<canvas id='mycanvas' width='600' height="600"></canvas>
import imgsrc from '@/assets/logo.png';
getcanvas() {
let mycanvas = document.querySelector("#mycanvas");
const ctx = mycanvas.getContext("2d");
var img = new Image();
img.src = imgsrc;
img.onload = function() {
// console.log(111)
ctx.drawImage(img,0,0, 50, 50);
console.log(img);
}
},
解决:把图片的路径import引进来,img.src赋值引入的路径;