npm install prismjs -S
npm install vite-plugin-prismjs -D
# or
yarn add prismjs -S
yarn add vite-plugin-prismjs -D
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { prismjsPlugin } from "vite-plugin-prismjs";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
prismjsPlugin({
languages: "all", // 语言
plugins: ["line-numbers", "show-language", "copy-to-clipboard", "inline-color"],
theme: "okaidia", // 主题
css: true,
}),
],
});
import Prism from "prismjs";
// 如果dom元素已经渲染完成
useEffect(() => {
if (content.length > 0) {
try {
Prism.highlightAll();
} catch (error) {
console.log(error);
}
}
}, [content]);
此页面不支持夜间模式!
已进入夜间模式!
已进入普通模式!
搜索框不允许为空
签到成功!经验+5!芋圆币+2!
签到失败!今日已签到!
需要登录社区账号才可以进入!