Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(clipboard): when click the copy button the data is not copied wit…
…h `v-clipboard:copy` Error: - When the copy button is pressed a success alert is displayed, but the console message `Clipboard input is empty` appears. - This message appears despite fixing the issue, it is a package problem and is not fixed at this time. Reason: - The `v-clipboard:copy` directive of the `vue-clipboard2` package does not exist in the `v-clipboard` package. - When using the `v-clipboard` directive of the `v-clipboard` package to execute a method (`copyData`), it no longer returns the copied value (`json`) by itself, as towards the `v-clipboard:copy` directive of the `vue-clipboard2` package. Solution: - Replace the `v-clipboard:copy` directive with the `v-clipboard` directive. - The `copyData` method needs to use `this.$clipboard.copy(value)` or `Clipboard.copy(value)` to copy the value. In this case, since the package has been imported globally, `this.$clipboard.copy(value)` would be used, but with `setup` we cannot use `this`. So import `Clipboard` from `v-clipboard` package into the component and use `Clipboard.copy(value)` instead. You need to globally import the `v-clipboard` package to use the `v-clipboard` directive. References: - euvl/v-clipboard#39 - https://www.npmjs.com/package/vue-clipboard2 - https://www.npmjs.com/package/v-clipboard - https://codesandbox.io/p/sandbox/mystifying-breeze-csgc5f?file=%2Fsrc%2FApp.vue%3A43%2C7-43%2C22
- Loading branch information