//等比例设置图片
let maxWidth = 100;
let maxHeight = 100;
let width = image.width;
let height = image.height;
// 计算新的尺寸
if (width > height) {
if (width > maxWidth) {
height = Math.round((height *= maxWidth / width));
width = maxWidth;
}
} else {
if (height > maxHeight) {
width = Math.round((width *= maxHeight / height));
height = maxHeight;
}
}
image.style.width=width+"px"
image.style.height=height+"px"