@@ -13,16 +13,17 @@ defineProps<{
13
13
14
14
const app = useAppStore ()
15
15
16
+ const sfcContainer = ref <HTMLElement | null >(null )
17
+
16
18
/**
17
19
* Download image
18
20
*/
19
21
async function download() {
20
- const container = document .getElementById (' spring-festival-container' )
21
- if (! container )
22
+ if (! sfcContainer .value )
22
23
return
23
24
// const url = await screenShotToBase64(container)
24
25
25
- const url = await toPng (container , {
26
+ const url = await toPng (sfcContainer . value , {
26
27
includeQueryParams: true ,
27
28
})
28
29
@@ -34,12 +35,11 @@ async function download() {
34
35
* Copy image to clipboard
35
36
*/
36
37
async function copyImg() {
37
- const container = document .getElementById (' girid-container' )
38
- if (! container )
38
+ if (! sfcContainer .value )
39
39
return
40
40
// const url = await screenShotToBase64(container)
41
41
42
- const blob = await toBlob (container , {
42
+ const blob = await toBlob (sfcContainer . value , {
43
43
includeQueryParams: true ,
44
44
})
45
45
@@ -60,7 +60,7 @@ async function shareLink() {
60
60
</script >
61
61
62
62
<template >
63
- <div id =" spring-festival-container" flex =" col" class =" font-zmx spring-festival-container" >
63
+ <div id =" spring-festival-container" ref = " sfcContainer " flex =" col" class =" font-zmx spring-festival-container" >
64
64
<div class =" font-zmx m-auto bg-#ff0000 p-2" w =" 50" text =" 4xl black" >
65
65
{{ coupletsData['横批'] }}
66
66
</div >
0 commit comments