安装html2canvas
npm install --save html2canvas
在所需页面引入
import html2canvas from "html2canvas"
Html
// ref="codeRef"为转换的html内容
<div ref="codeRef" style="display: flex;justify-content: center;background: #d4f6fa;flex-direction: column;align-items: center;position:relative">
<div style="font-weight: bold; letter-spacing: 1px; font-family: sans-serif; text-align: center; font-size: 20px; color: #37a0f4; padding: 0 32px; line-height: 35px; ">
{
{this.form.name}}
</div>
<div style="width:100%;overflow:hidden;position:relative">
<img src="../../../../assets/yym.jpg" style="width:100%" />
<div id="yyqrcode" style="position: absolute; left: 50%; margin-left: -94px; top: 79px; "></div>
</div>
//newimg为