mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-27 05:00:48 +08:00
877 B
877 B
Code
Prequisites
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.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.
import Vue from 'vue'
import NaiveUI from 'naive-ui'
import hljs from 'highlight.js/lib/highlight'
import cpp from 'highlight.js/lib/languages/cpp'
hljs.registerLanguage('cpp', cpp)
Vue.use(NaiveUI)
NaiveUI.setHljs(hljs)
Demos
basic
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 |