2019-12-13 22:34:38 +08:00
# Code
2019-12-13 23:03:41 +08:00
2019-12-13 23:55:19 +08:00
## Prequisites
2020-02-07 23:40:07 +08:00
< n-alert title = "Note" type = "warning" style = "margin-bottom: 16px;" >
2019-12-13 23:55:19 +08:00
Due to package size, Naive UI doesn't include highlight.js. If you want use Code, make sure you have set highlightjs before using it.
2019-12-13 23:03:41 +08:00
< / n-alert >
2019-12-13 23:55:19 +08:00
The following code shows how to set hljs of Naive UI. Importing highlight.js on demand is recommonded, because it can significantly reduce bundle size of your app.
```js
import Vue from 'vue'
import NaiveUI from 'naive-ui'
import hljs from 'highlight.js/lib/highlight'
2019-12-22 15:58:51 +08:00
import cpp from 'highlight.js/lib/languages/cpp'
2019-12-13 23:55:19 +08:00
hljs.registerLanguage('cpp', cpp)
Vue.use(NaiveUI)
NaiveUI.setHljs(hljs)
```
2019-12-13 23:03:41 +08:00
## Demos
2019-12-13 22:34:38 +08:00
```demo
basic
2020-01-30 21:19:53 +08:00
```
## Props
|Name|Type|Default|Description|
|-|-|-|-|
|language|`string`|`null`||
|code|`string`|`null`||
|trim|`boolean`|`true`||
|hljs|`object`|`null`|If you want to set hljs locally, set it on code by the prop|