js 复制粘贴 element

 

<el-button @click="copyUrl(scope.row.activity_id)" size="small" border type="warning" plain>复制链接</el-button>
copyUrl(id) {
            let url = `<?php echo $output['gp_site_url']?>/activity/${id}`;
            let _input = document.createElement("input");   //创建input元素
            _input.value = url;  // 赋值要复制的内容
            document.body.appendChild(_input);    // 添加
            _input.select();   // 选择
            document.execCommand("Copy");   // 复制
            document.body.removeChild(_input); // 删除
            this.$message({
                message: '复制成功',
                type: 'success',
                duration: 1500
            });
        }

 


版权声明:本文为someWhere_weMeet原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。