[fix] copy failure (#446)

This commit is contained in:
星日语 2024-04-26 01:41:53 +08:00 committed by GitHub
parent ae9700a4ad
commit 988a88e196
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -7,7 +7,7 @@ window.codeElements.forEach((codeElement) => {
// 添加点击事件监听 // 添加点击事件监听
codeCopyBtn.addEventListener('click', async () => { codeCopyBtn.addEventListener('click', async () => {
const codeToCopy = codeElement.querySelector('code')?.textContent || ''; const codeToCopy = codeElement.querySelector('pre')?.innerText || '';
if (navigator.clipboard) { if (navigator.clipboard) {
try { try {
await navigator.clipboard.writeText(codeToCopy); await navigator.clipboard.writeText(codeToCopy);