我有将浏览器的 url 复制到剪贴板的功能:
const preCopy = "Copy Link"
const postCopy = "Copied Link"
function copyURI(evt) {
evt.preventDefault()
navigator.clipboard.writeText(evt.target.getAttribute("href")).then(
() => {
evt.target = postCopy
setTimeout(() => {
evt.target = preCopy
}, 30000)
},
() => {}
)
}
我想在单击此文本链接时在此处实施此操作:
<text>
"Copy Link"
</text>
这是可能的还是我需要一个按钮?我怎么能做到这一点?谢谢