html5复制命令
作者:
sorry510 | 来源:发表于
2019-12-08 18:41 被阅读0次const copy = text=> {
const textArea = document.createElement("textarea")
textArea.style.position = 'fixed'
textArea.style.top = 0
textArea.style.left = 0
textArea.style.width = '2em'
textArea.style.height = '2em'
textArea.style.padding = 0
textArea.style.border = 'none'
textArea.style.outline = 'none'
textArea.style.boxShadow = 'none'
textArea.style.background = 'transparent'
textArea.value = text
document.body.appendChild(textArea)
textArea.select()
try {
var msg = document.execCommand('copy') ? '成功' : '失败'
console.log('复制内容 ' + msg)
} catch (err) {
console.log('不能使用这种方法复制内容')
}
document.body.removeChild(textArea)
}
本文标题:html5复制命令
本文链接:https://www.haomeiwen.com/subject/vpdbvctx.html
网友评论