const _input = document.createElement('input')
_input.value = ‘http://www.baidu.com’
document.body.appendChild(_input)
_input.select()
document.execCommand('Copy')
document.body.removeChild(_input)
this.$message.warning('复制成功')
本文介绍了如何使用JavaScript操作DOM,创建一个隐藏的input元素,设置其值为URL,选择内容后执行复制命令,最后移除元素并显示复制成功的警告消息。
const _input = document.createElement('input')
_input.value = ‘http://www.baidu.com’
document.body.appendChild(_input)
_input.select()
document.execCommand('Copy')
document.body.removeChild(_input)
this.$message.warning('复制成功')
302
370
145
3355
923

被折叠的 条评论
为什么被折叠?