值得参考:
https://blog.csdn.net/weixin_43392489/article/details/108368993
利用htmlToCanvas生成缩略图
文档地址:
http://html2canvas.hertzen.com/
没找到中文文档
const htmlCanvas = await html2canvas(
document.querySelector('.target')
);
const { width, height } = htmlCanvas;
// 生成canvas的大小
let num;
if (width >= 500 || height >= 500) {
num = 500 / width;
} else {
num = 1.0;
}
this.thumbnailBase = htmlCanvas.toDataURL('image/jpeg', num);
canvas
https://developer.mozilla.org/zh-CN/docs/Web/API/Canvas_API
网友评论