工具 & 库
html2canvas
解决清晰度问题,部分手机不兼容,
dpi
太高会有兼容问题使用这个版本: https://hzxdffe-static.oss-cn-hangzhou.aliyuncs.com/public/html2canvas.min.js
async function createPoster() {
const element = document.getElementById('html2canvas') as HTMLElement
const options = {
dpi: window.devicePixelRatio * 300,
useCORS: true,
width: 375,
height: 667,
}
if (window.html2canvas) {
window
.html2canvas(element, options)
.then((canvas: any) => {
posterUrl.value = canvas.toDataURL('image/png')
})
.catch((error: any) => {
console.log('error', error)
})
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
生成二维码
图片压缩
省市区数据
Cmder
widow下的命令行工具