js复制功能

// 复制功能
    copyLink() {
      const input = document.createElement('input')
      // 将input的值设置为需要复制的内容
      input.value = 'https://www.baidu.com'
      // 添加input标签
      document.body.appendChild(input)
      // 选中input标签
      input.select()
      // 执行复制
      document.execCommand('copy')
      // 成功提示信息
      this.$message.success('复制成功!')
      // 移除input标签
      document.body.removeChild(input)
    },
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容