vue + mavon-editor


推荐一个markdown编辑器:mavon-editor

  1. Install mavon-editor (安装)
npm install mavon-editor --save
  1. 全局引入(main.js)
import Vue from 'vue'
import mavonEditor from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'

Vue.use(mavonEditor)
  1. 在组件中引入





image

markdown 语法的字符串在前端显示

  1. 安装 showdown 模块
npm install showdown --save
  1. 引入
import showdown from 'showdown'
  1. 使用
let converter = new showdown.Converter()// 初始化转换器
let html = converter.makeHtml(text)// 将 markdown 语法的字符串转换为 html