euvl/v-clipboard
소개
Vue.js 2와 3을 위한 간편하고 강력한 클립보드 플러그인
웹 및 앱 개발측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- -1
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalSupporters
Check them out.
Install
npm install --save v-clipboard
yarn add v-clipboard
import Vue from 'vue'
import Clipboard from 'v-clipboard'
Vue.use(Clipboard)
Usage
When an element that contains v-clipboard directive is clicked, the value of value will be copied into clipboard.
Copying static value (directive should receive actual value):
<button v-clipboard="value">
Copy to clipboard
</button>
<button v-clipboard="'some text'">
Copy to clipboard
</button>
Copying dynamic value (directive should recieve a function that returns value):
<button v-clipboard="() => value">
Copy to clipboard
</button>
Copying anything in your methods:
this.$clipboard(value)
Without plugin:
import { Clipboard } from 'v-clipboard'
await Clipboard.copy(value)
Events
<button
v-clipboard="foo"
v-clipboard:success="clipboardSuccessHandler"
v-clipboard:error="clipboardErrorHandler"
>
Copy to clipboard
</button>
{
methods: {
clipboardSuccessHandler (value, event) {
console.log('success', value)
},
clipboardErrorHandler (value, event) {
console.log('error', value)
}
}
}
How it works
copy / $clipboard is an async call. Firstly, library makes an attempt to update clibpoard using execCommand, if that operation is unsuccessful it makes an attemnt to use Navigator Clipboard API and automatically requests access, waits for access to be granted, then writes to clipboard.
Demo
https://codesandbox.io/s/epic-waterfall-17yet5?file=/src/App.vue
Compatibility
관련 프로젝트 살펴보기
불러오는 중…