wqy
2020-06-06 17:01:47
5633

1 首先在项目中安装prismjs插件:

cnpm install prismjs -S

 

2 安装完成后,需要继续安装一个prismjs的编译器插件

cnpm install babel-plugin-prismjs -D

 

3 在.babelrc文件中配置使用该插件:

 

{
  "plugins": [
    ["prismjs", {
      "languages": ["javascript", "css", "markup"],
      "plugins": ["line-numbers"],
      "theme": "twilight",
      "css": true
    }]
  ]
}

4 支持的主题

default
dark
funky

okaidia
twilight

coy
solarizedlight



5 prismjs 官网地址:https://prismjs.com/