我如何设置在chrome应用程序的图像的宽度和高度

How do i set the width and height of the image in chrome app?

本文关键字:图像 应用程序 高度 chrome 何设置 设置      更新时间:2023-09-26
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://supersweetdomainbutnotcspfriendly.com/image.png',true);
xhr.responseType = 'blob';
xhr.onload = function(e) {
var img = document.createElement('img');
img.src = window.URL.createObjectURL(this.response);
document.body.appendChild(img);
};
xhr.send();

通过使用这个,我可以得到图像,但默认大小。请告诉我如何设置图像的宽度和高度?

可以在var img = document.createElement('img');

下面添加两行
img.setAttribute('width', '100');
img.setAttribute('height', '100');