//html部分
<p @click="fuzhi('我是复制的内容')">复制链接</p>
//js
fuzhi(text){
var copyInput = document.createElement('input')
copyInput.setAttribute('value', text)
document.body.appendChild(copyInput)
copyInput.select()
var copyed = document.execCommand('copy')
if (copyed) {
document.body.removeChild(copyInput)
this.$message.success('复制成功');
}
}
简易版点击复制文本功能
最新推荐文章于 2024-07-06 16:47:02 发布