位置:首页 > Vue >

vue点击复制指定内容

字号+ 作者:micloud 来源:www.seoalphas.com 2022-09-22 14:50 浏览量:1030

原理比较简单,直接贴出来代码:

//复制操作
copyUrl(data) {
  let oInput = document.createElement('input')
    oInput.value = data
    document.body.appendChild(oInput)
    oInput.select() // 选择对象
    document.execCommand("Copy") // 执行浏览器复制命令
    this.$message({
         message: '复制成功',
         type: 'success'
    })              
  oInput.remove()
},

  上面代码中,参数data即为待复制的内容,其实就是js相关语法的应用。

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • vue点击事件@click.stop(阻止冒泡).native

    vue点击事件@click.stop(阻止冒泡).native

    浏览次数:8847

  • Vue+Element UI Radio默认选中问题 selected

    Vue+Element UI Radio默认选中问题 selected

    浏览次数:7825

  • vue设置网页页面title--router

    vue设置网页页面title--router

    浏览次数:2584

  • vue img标签:onerror="defaultImg"或@error=“defImg()” 使用

    vue img标签:onerror="defaultImg"或@error=“defImg()” 使用

    浏览次数:2347

网友点评
评论区域