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(){