html代码:
<el-input id="copy" style="width: 400px;" readonly v- model="linkUrl">
<template slot="append">
<span class="pointer" @click="copyAdress">复制</span>
</template>
</el-input>
js代码:要写select(),不然复制不了
copyAdress() {
var copy = document.getElementById('copy')
copy.select()
document.execCommand('copy')
this.$message.success(this.$t('message.copyMsg'))
}
网友评论