Last active
November 19, 2020 10:27
-
-
Save VisualBean/2663dba0b25f82ea2ecdb6eed88fba9b to your computer and use it in GitHub Desktop.
simple use of legacy copy and paste
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div id="app"> | |
<input | |
v-on:focus="$event.target.select()" | |
ref="myinput" | |
readonly | |
:value="text"/> | |
<button @click="copy">Copy</button> | |
</div> | |
</template> | |
<script> | |
export default { | |
data() { | |
return { | |
text: 'This will get copied!' | |
}; | |
}, | |
methods: { | |
copy() { | |
this.$refs.myinput.focus(); | |
document.execCommand('copy'); | |
} | |
} | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment