Skip to content

Commit 2423f2f

Browse files
zhangzheng-zzInndy
authored andcommitted
feat: Compatible with vue3
1 parent 3d7ea0b commit 2423f2f

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-clipboard2",
3-
"version": "0.3.1",
4-
"description": "A Vuejs2 binding for clipboard.js",
3+
"version": "0.3.2",
4+
"description": "A Vuejs2 & Vuejs3 binding for clipboard.js",
55
"main": "vue-clipboard.js",
66
"scripts": {
77
"build": "$(npm bin)/eslint vue-clipboard.js && $(npm bin)/browserify browserify-me.js -o dist/vue-clipboard.js && $(npm bin)/uglifyjs dist/vue-clipboard.js -o dist/vue-clipboard.min.js && echo Success"

vue-clipboard.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ var VueClipboardConfig = {
77

88
var VueClipboard = {
99
install: function (Vue) {
10-
Vue.prototype.$clipboardConfig = VueClipboardConfig
11-
Vue.prototype.$copyText = function (text, container) {
10+
var globalPrototype = Vue.version.slice(0, 2) === '3.' ? Vue.config.globalProperties : Vue.prototype
11+
globalPrototype.$clipboardConfig = VueClipboardConfig
12+
globalPrototype.$copyText = function (text, container) {
1213
return new Promise(function (resolve, reject) {
1314
var fakeElement = document.createElement('button')
1415
var clipboard = new Clipboard(fakeElement, {

0 commit comments

Comments
 (0)