|
@@ -142,7 +142,7 @@ export default {
|
|
methods: {
|
|
methods: {
|
|
onClickSave: globalUtils.throttle(function() {
|
|
onClickSave: globalUtils.throttle(function() {
|
|
this.isSaving = true
|
|
this.isSaving = true
|
|
- setTimeout(() => {
|
|
|
|
|
|
+ this.$nextTick(() => {
|
|
// #capture 就是我们要获取截图对应的 DOM 元素选择器
|
|
// #capture 就是我们要获取截图对应的 DOM 元素选择器
|
|
html2canvas(document.querySelector('#capture'), {
|
|
html2canvas(document.querySelector('#capture'), {
|
|
useCORS: true, // 【重要】开启跨域配置
|
|
useCORS: true, // 【重要】开启跨域配置
|
|
@@ -151,12 +151,12 @@ export default {
|
|
preserveDrawingBuffer: true,
|
|
preserveDrawingBuffer: true,
|
|
}).then((canvas) => {
|
|
}).then((canvas) => {
|
|
this.aDownloadHref = canvas.toDataURL('image/jpeg', 1.0)
|
|
this.aDownloadHref = canvas.toDataURL('image/jpeg', 1.0)
|
|
- setTimeout(() => {
|
|
|
|
|
|
+ this.$nextTick(() => {
|
|
this.$refs['for-download'].click()
|
|
this.$refs['for-download'].click()
|
|
this.isSaving = false
|
|
this.isSaving = false
|
|
- }, 300)
|
|
|
|
|
|
+ })
|
|
})
|
|
})
|
|
- }, 300) // 这里加上 300ms 的延迟是为了让 DOM 元素完全渲染完成后再进行图片的生成
|
|
|
|
|
|
+ })
|
|
}, 400)
|
|
}, 400)
|
|
}
|
|
}
|
|
}
|
|
}
|