通过vue插件html2canvas截图

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

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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>

3.js

<script>
import html2canvas from 'html2canvas';
export default {

  data() {
    return {};
  },
  methods:{
    sa(){
  
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值