下载:npm install codemirror@4.0.6 --save
main.js
import VueCodemirror from "vue-codemirror";
import "codemirror/lib/codemirror.css";
Vue.use(VueCodemirror);
组件--RichText.vue
<template>
<div class="code-mirror-box">
<textarea ref="textareaCoder"></textarea>
</div>
</template>
<script>
// 引入全局实例
import _CodeMirror from "codemirror";
// language
import "codemirror/mode/javascript/javascript.js";
// 核心样式
import "codemirror/lib/codemirror.css";
// 引入主题后还需要在 options 中指定主题才会生效
import "codemirror/theme/monokai.css";
// active-line
import "codemirror/addon/selection/active-line.js";
// foldGutter
import "codemirror/addon/fold/foldgutter.css";
import "codemirror/addon/fold/brace-fold.js";
import "codemirror/addon/fold/comment-fold.js";
import "codemirror/addon/fold/foldco