美文网首页
vue中原生js方法实现点击复制

vue中原生js方法实现点击复制

作者: Sven0706 | 来源:发表于2018-06-22 11:37 被阅读0次
methods: {
    Copy(copyInfo) {
         return new Promise((resolve, reject) => {
            let copyUrl = document.createElement("input"); //创建一个input框获取需要复制的文本内容
            copyUrl.value = copyInfo;
            let appDiv = document.getElementById('app');
            appDiv.appendChild(copyUrl);
            copyUrl.select();
            document.execCommand("Copy");
            copyUrl.remove()
            resolve(true);
         })
     }
  }

相关文章

网友评论

      本文标题:vue中原生js方法实现点击复制

      本文链接:https://www.haomeiwen.com/subject/mdhkyftx.html