<div>
<input type="text" ref="ipt" v-model="value">
<button @click="copy">复制</button>
</div>
<script>
methods: {
export default {
data() {
return {
value:'123456'
};
},
methods:{
copy(){
this.$refs.ipt.select()
document.execCommand('Copy')
},
}
}
}
</script>