Skip to content

Commit d6c75b0

Browse files
committed
🐛 fix: alertify 修复
1 parent 1b8ddd1 commit d6c75b0

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

docs/components/CopyButton.vue

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
<script setup>
22
import copy_text from '../utils/copy.js'
3-
import alertify from 'alertifyjs'
4-
5-
import { ref } from 'vue'
6-
3+
import { ref, onMounted } from 'vue'
74
85
const props = defineProps({
96
label: {
107
type: String,
11-
default: "比特币地址:" // 默认值
8+
default: "比特币地址:"
129
},
1310
text: {
1411
type: String,
@@ -17,19 +14,26 @@ const props = defineProps({
1714
})
1815
1916
const copied = ref(false)
17+
// 用来存放客户端导入的 alertify
18+
let alertify = null
19+
20+
// 仅在浏览器端加载 alertifyjs
21+
onMounted(async () => {
22+
alertify = (await import('alertifyjs')).default
23+
})
24+
2025
const handleCopy = () => {
2126
copy_text(props.text)
2227
.then(() => {
2328
copied.value = true
2429
setTimeout(() => (copied.value = false), 2000)
2530
console.log('复制成功:', props.text)
26-
alertify.success('复制成功!')
31+
if (alertify) alertify.success('复制成功!')
2732
})
2833
.catch(() => {
29-
alertify.warning('复制失败~')
34+
if (alertify) alertify.warning('复制失败~')
3035
})
3136
}
32-
3337
</script>
3438

3539
<template>

0 commit comments

Comments
 (0)