[fix] copy failure (#446)
This commit is contained in:
parent
ae9700a4ad
commit
988a88e196
|
@ -7,7 +7,7 @@ window.codeElements.forEach((codeElement) => {
|
|||
|
||||
// 添加点击事件监听
|
||||
codeCopyBtn.addEventListener('click', async () => {
|
||||
const codeToCopy = codeElement.querySelector('code')?.textContent || '';
|
||||
const codeToCopy = codeElement.querySelector('pre')?.innerText || '';
|
||||
if (navigator.clipboard) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(codeToCopy);
|
||||
|
|
Loading…
Reference in New Issue