前端的复制功能
<span class="copy" @click="autoCopyUrl()" ref="invitUrl">复制</span>
autoCopyUrl() {
const input = document.createElement('input')
const url = this.$refs.invitUrl.innerText
document.body.appendChild(input)
input.setAttribute('value', url)
input.select()
if (document.execCommand('copy')) {
document.execCommand('copy')
this.$message.success('复制分享链接成功')
}
document.body.removeChild(input)
}
网友评论