vue - 一键复制,不用插件

 copy(text) {
            var Input = document.createElement('input'); //创建一个隐藏input(重要!)
            Input.value = text; //赋值
            document.body.appendChild(Input);
            Input.select(); // 选择对象
            document.execCommand('Copy'); // 执行浏览器复制命令
            Input.className = 'oInput';
            Input.style.display = 'none';
            this.$message({ message: '复制成功', type: 'success' });
        },
posted @ 2020-06-18 17:40  gggggggxin  阅读(396)  评论(1编辑  收藏  举报