🛠️

19302 工具站

在线工具集合

文章/js复制文字

js复制文字

2020年09月22日3,234 次阅读⏱ 约 1 分钟JavaScript
selectText(name) {
	let text = name;
	let oInput = document.createElement('input');
	oInput.value = text;
	document.body.appendChild(oInput);
	oInput.select(); // 选择对象;
	console.log(oInput.value);
	document.execCommand("Copy"); // 执行浏览器复制命令
	this.$toast('复制成功');
	oInput.remove();
}

💬评论(0)

💭

暂无评论