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
}


原文地址:

延伸阅读
  1. 用threejs展示stl格式3D模型
  2. layui Tree