marked
cnpm install marked S
cnpm install highlight.js S
import marked from 'marked';
import hljs from 'highlight.js'
import 'highlight.js/styles/atom-one-dark.css'
编辑区
<el-input type='textarea' :rows='31' v-model="article.content" ></el-input>
预览区
<div class="box" style="width:50%;float:left" v-html="compiledMarkdown"></div>
computed: {
compiledMarkdown: function () {
return marked(this.article.content, {
sanitize: true,
breaks: true,
highlight: function(code, lang) {
return hljs.highlightAuto(code, [lang]).value;
}
})
}
},