20
10月
2021
function copyText(value) { const element = document.createElement('textarea') document.body.appendChild(element) element.value = value element.select() // 选择 if (document.execCommand('copy')) { // 判定是否支持复制(兼容问题) document.execCommand('copy') // 复制 document.body.removeChild(element) return true } document.body.removeChild(element) return false }