在PC页面中实现点击一个链接,复制到粘贴板上
思路:
1、创建一个新标签input
2、把要复制的链接添加里面
3、通过document.execCommand函数将其复制到粘贴板上
4、移除input
execComman 函数好像只能复制input里的 value值(仅供参考)
shareUrl(share) {
//share 链接地址
var tag = document.createElement("input");
tag.setAttribute("id", "share_url");
tag.value = share;
document.getElementsByTagName("body")[0].appendChild(tag);
document.getElementById("share_url").select();
document.execCommand("copy");
document.getElementById("share_url").remove();
this.$message.success("复制成功");
},