Skip to content

Commit

Permalink
feat: Compatible with vue3
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzheng-zz authored and Inndy committed Sep 10, 2021
1 parent 3d7ea0b commit 2423f2f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vue-clipboard2",
"version": "0.3.1",
"description": "A Vuejs2 binding for clipboard.js",
"version": "0.3.2",
"description": "A Vuejs2 & Vuejs3 binding for clipboard.js",
"main": "vue-clipboard.js",
"scripts": {
"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"
Expand Down
5 changes: 3 additions & 2 deletions vue-clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ var VueClipboardConfig = {

var VueClipboard = {
install: function (Vue) {
Vue.prototype.$clipboardConfig = VueClipboardConfig
Vue.prototype.$copyText = function (text, container) {
var globalPrototype = Vue.version.slice(0, 2) === '3.' ? Vue.config.globalProperties : Vue.prototype
globalPrototype.$clipboardConfig = VueClipboardConfig
globalPrototype.$copyText = function (text, container) {
return new Promise(function (resolve, reject) {
var fakeElement = document.createElement('button')
var clipboard = new Clipboard(fakeElement, {
Expand Down

0 comments on commit 2423f2f

Please sign in to comment.