js implements text copy

copy(val) {
    
    
	let oInput = window.document.createElement('input')
	oInput.value = val
	window.document.body.appendChild(oInput)
	oInput.select() // 选择对象;
	window.document.execCommand('Copy') // 执行浏览器复制命令

	window.alert('复制成功')

	oInput.remove()
},

More other copying solutions: How to copy text through js js to operate the clipboard

Guess you like

Origin blog.csdn.net/weixin_34403976/article/details/128254086