一、安装依赖(我用的yarn,如果是npm/pnpm等就换下指令执行)
yarn add @kangc/v-md-editor
yanr add highlight.js
二、在main.js中引入
import Vue from 'vue';
import VMdEditor from '@kangc/v-md-editor';
import '@kangc/v-md-editor/lib/style/base-editor.css';
import githubTheme from '@kangc/v-md-editor/lib/theme/github.js';
import '@kangc/v-md-editor/lib/theme/style/github.css';
// highlightjs
import hljs from 'highlight.js';
VMdEditor.use(githubTheme, {
Hljs: hljs,
});
Vue.use(VMdEditor);
三、使用
<template>
<div>
<v-md-editor v-model="text" height="400px"></v-md-editor>
</div>
</template>
<script>
export default {
data() {
return {
text:'## 123456'
}
},
}
</script>
四、官方文档
v-md-editor