您现在的位置是:首页 > 网站制作 > vue.js心得vue.js心得
vue复制粘贴功能
蒙xs2022-01-04【vue.js心得】人已围观
简介copyUrl('string')copyUrl(url) { var domUrl = document.createElement("input"); domUrl.value = url; domUrl.id = "creatDom"; document.body.appe
copyUrl('string')
copyUrl(url) {
var domUrl = document.createElement("input");
domUrl.value = url;
domUrl.id = "creatDom";
document.body.appendChild(domUrl);
domUrl.select(); // 选择对象
document.execCommand("Copy"); // 执行浏览器复制命令
let creatDom = document.getElementById("creatDom");
creatDom.parentNode.removeChild(creatDom);
alert("已复制好,可贴粘。");
}
Tags:
很赞哦! ()