美文网首页
canvas && htmlToCanvas

canvas && htmlToCanvas

作者: Rose_yang | 来源:发表于2021-08-04 10:09 被阅读0次

    值得参考:
    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

    相关文章

      网友评论

          本文标题:canvas && htmlToCanvas

          本文链接:https://www.haomeiwen.com/subject/cptuvltx.html