Skip to content

Instantly share code, notes, and snippets.

@VisualBean
Last active November 19, 2020 10:27
Show Gist options
  • Save VisualBean/2663dba0b25f82ea2ecdb6eed88fba9b to your computer and use it in GitHub Desktop.
Save VisualBean/2663dba0b25f82ea2ecdb6eed88fba9b to your computer and use it in GitHub Desktop.
simple use of legacy copy and paste
<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