#I3BMNS 代码块高亮,增加判空和状态判断

This commit is contained in:
暮光:城中城
2021-11-01 22:44:11 +08:00
parent 7b4c1ae455
commit d3ed4e8334
7 changed files with 62 additions and 4 deletions

View File

@@ -32,6 +32,18 @@ let vue = new Vue({
return h(App);
}
});
// 注册一个全局自定义指令
import hljs from 'highlight.js'
import 'highlight.js/styles/googlecode.css'
Vue.directive('highlight', function (el) {
let blocks = el.querySelectorAll('pre code');
blocks.forEach((block) => {
hljs.highlightBlock(block);
})
});
export default vue;