Created
August 6, 2021 07:02
-
-
Save VisualBean/26c98a125af30cd6d6bf71c5a9def460 to your computer and use it in GitHub Desktop.
vuejs copy paste
This file contains hidden or 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="clone" | |
readonly | |
:value="text"/> | |
<button @click="copy">Copy</button> | |
</div> | |
</template> | |
<script> | |
export default { | |
data() { | |
return { | |
text: 'This will get copied!' | |
}; | |
}, | |
methods: { | |
copy() { | |
this.$refs.clone.focus(); | |
document.execCommand('copy'); | |
} | |
} | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment