你来进行优化const codeBlocks = documentquerySelectorAllarticle pre code; codeBlocksforEachcodeBlock = const sanitizedContent = DOMPurifysanitizecodeBlock; hljshighlightBlocksanitizedC
可以将代码优化如下:
const codeBlocks = document.querySelectorAll('article pre code');
codeBlocks.forEach((codeBlock) => {
hljs.highlightBlock(codeBlock);
});
上述代码移除了注释行,因为DOMPurify.sanitize()方法似乎没有被使用。
原文地址: http://www.cveoy.top/t/topic/iCcL 著作权归作者所有。请勿转载和采集!