Skip to content

Commit

Permalink
docs(useClipboard): update demo and type fixes (#2430)
Browse files Browse the repository at this point in the history
* docs: update copy() method to include argument.
* docs: update useClipboard demo to be more detailed and self-explanatory

Co-authored-by: wheat <jacobrclevenger@gmail.com>
  • Loading branch information
solamichealolawale and wheatjs committed Jan 17, 2023
1 parent f328a14 commit 691622a
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions packages/core/useClipboard/index.md
Expand Up @@ -18,11 +18,19 @@ const { text, copy, copied, isSupported } = useClipboard({ source })
```

```html
<button @click='copy()'>
<!-- by default, `copied` will be reset in 1.5s -->
<span v-if='!copied'>Copy</span>
<span v-else>Copied!</span>
</button>
<div v-if="isSupported">
<button @click='copy(source)'>
<!-- by default, `copied` will be reset in 1.5s -->
<span v-if='!copied'>Copy</span>
<span v-else>Copied!</span>
</button>
<p>
Current copied: <code>{{ text || 'none' }}</code>
</p>
</div>
<p v-else>
Your browser does not support Clipboard API
</p>
```

Set `legacy: true` to keep the ability to copy if [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API) is not available. It will handle copy with [execCommand](https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand) as fallback.

0 comments on commit 691622a

Please sign in to comment.