网站平台开发报价表怎么做,建设一个电商网站的步骤,都有哪些网站,wordpress 无刷新跳转问题
现在我有一个动态的 html 节点#xff0c;我想用 vue 渲染后#xff0c;传递给后端保存 思路 本来想给html的#xff0c;发现样式是个问题 在一个是打印成pdf#xff0c;然后上传#xff0c;这个操作就变多了 最后的思路是通过 html2canvas 转化成 canvas 然后变成…问题
现在我有一个动态的 html 节点我想用 vue 渲染后传递给后端保存 思路 本来想给html的发现样式是个问题 在一个是打印成pdf然后上传这个操作就变多了 最后的思路是通过 html2canvas 转化成 canvas 然后变成 blob 然后变成 base64String 用到的库叫 html2canvas
import html2canvas from html2canvas
html2canvas(dom).then(async function (canvas) {// 将 Canvas 转换为 Blob 或 Base64 字符串const blob await new PromiseBlob((resolve: any) {canvas.toBlob(resolve, image/png)})// 将 Blob 转换为 Base64 字符串const base64String await new Promisestring(resolve {const reader new FileReader()reader.onloadend () resolve(reader.result as string)reader.readAsDataURL(blob)})const params {id,html: base64String}await SaveHTML(params)
})