mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-15 04:29:37 +01:00
docs(examples): use useClipboard instead of navigator.clipboard
This commit is contained in:
@@ -1,15 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { useClipboard } from '@vueuse/core'
|
||||
|
||||
const value = ref('npx nuxt module add ui')
|
||||
const copied = ref(false)
|
||||
|
||||
function copy() {
|
||||
navigator.clipboard.writeText(value.value)
|
||||
copied.value = true
|
||||
|
||||
setTimeout(() => {
|
||||
copied.value = false
|
||||
}, 2000)
|
||||
}
|
||||
const { copy, copied } = useClipboard()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -25,7 +19,7 @@ function copy() {
|
||||
size="sm"
|
||||
:icon="copied ? 'i-lucide-copy-check' : 'i-lucide-copy'"
|
||||
aria-label="Copy to clipboard"
|
||||
@click="copy"
|
||||
@click="copy(value)"
|
||||
/>
|
||||
</UTooltip>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user