const target = document.createElement('input') // 创建input节点
target.value = text // 给input的value赋值
document.body.appendChild(target) // 向页面插入input节点
target.select() // 选中input
try {
document.execCommand('Copy') // 执行浏览器复制命令
this.$message({
message: '复制成功',
type: 'success'
})
} catch {
console.log('复制失败')
}
js 直接复制文本内容
最新推荐文章于 2023-10-28 22:42:20 发布