1.安装html2canvas
npm install html2canvas
2.页面
<template>
<div>
<div id="map">
<div style="width:200px;height:200px;background:gray;"></div>
<!-- <img id="img" style="width:300px;height:200px;" src="https://img1.baidu.com/it/u=3438742520,3870787236&fm=253&app=138&size=w931&n=0&f=PNG&fmt=auto?sec=1675184400&t=a39984a80b350c83786f5b6f33e04b52" alt=""> -->
<img id="img" style="width:300px;height:200px;" src="http://localhost:8080/api/msg/resource\320000\照片资源\明信片2_画板 1 副本 4.png">
</div>
<img id="aaa" src="" />
<button @click="sa">ok</button>
</div>
</template>

本文介绍了如何在Vue项目中结合html2canvas插件实现网页内容的截图功能。首先通过npm安装html2canvas,然后在页面上设置相关元素,接着在js中编写处理逻辑,最后配合css调整样式。点击按钮即可触发截图操作。
最低0.47元/天 解锁文章
6044

被折叠的 条评论
为什么被折叠?



