fix copy to clipboard #132
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-dialog transition="dialog-bottom-transition" width="400">
|
<v-dialog transition="dialog-bottom-transition" width="400">
|
||||||
<v-card class="rounded-lg">
|
<v-card class="rounded-lg" id="qrcode-modal">
|
||||||
<v-card-title>
|
<v-card-title>
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col>QrCode</v-col>
|
<v-col>QrCode</v-col>
|
||||||
@@ -43,8 +43,13 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
copyToClipboard(txt:string) {
|
copyToClipboard(txt:string) {
|
||||||
|
const hiddenButton = document.createElement('button')
|
||||||
|
hiddenButton.className = 'clipboard-btn'
|
||||||
|
document.body.appendChild(hiddenButton)
|
||||||
|
|
||||||
const clipboard = new Clipboard('.clipboard-btn', {
|
const clipboard = new Clipboard('.clipboard-btn', {
|
||||||
text: () => txt
|
text: () => txt,
|
||||||
|
container: document.getElementById('qrcode-modal')?? undefined
|
||||||
});
|
});
|
||||||
|
|
||||||
clipboard.on('success', () => {
|
clipboard.on('success', () => {
|
||||||
@@ -58,11 +63,8 @@ export default {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Perform click on hidden button to trigger copy
|
// Perform click on hidden button to trigger copy
|
||||||
const hiddenButton = document.createElement('button');
|
hiddenButton.click()
|
||||||
hiddenButton.className = 'clipboard-btn';
|
document.body.removeChild(hiddenButton)
|
||||||
document.body.appendChild(hiddenButton);
|
|
||||||
hiddenButton.click();
|
|
||||||
document.body.removeChild(hiddenButton);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|||||||
Reference in New Issue
Block a user