我正在尝试提取图像(在这种情况下,/camera/frame是已知良好的 JPG),并将其加载为我的document.body.
到目前为止,这是我的代码:
var backgroundImage = new Image();
backgroundImage.onload = function ()
{
console.log("onload");
document.body.style.backgroundImage = this.src;
};
backgroundImage.src = 'camera/frame';
"onload"按预期打印,并且 this.src 打印出完整的 URL 到/camera/frame,但document.body.style.backgroundImage仍然存在""。