2022-01-21 14:31:01
- 1、引用 https://highlightjs.org/static/demo/styles/default.css
- 2、引用 https://highlightjs.org/static/highlight.site.pack.js
- 3、调用
hljs.highlightAll()
函数实例代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="https://highlightjs.org/static/demo/styles/default.css">
<script src="https://highlightjs.org/static/highlight.site.pack.js"></script>
<script>hljs.highlightAll();</script>
</head>
<body>
<div style="font-size: 18px;">
<pre>
<code class="language-javascript">
let dom = document.querySelector('body')
</code>
</pre>
</div>
</body>
</html>
输出结果
let dom = document.querySelector('body')
最后生成于 2023-06-27 21:38:06
热门推荐: