扫一扫分享
mavonEditor:基于 vue 的 Markdown 编辑器,支持所见即所得编辑模式、阅读模式等 
$ npm install mavon-editor --save
index.js:
// 全局注册
    // import with ES6
    import Vue from 'vue'
    import mavonEditor from 'mavon-editor'
    import 'mavon-editor/dist/css/index.css'
    // use
    Vue.use(mavonEditor)
    new Vue({
        'el': '#main',
        data() {
            return { value: '' }
        }
    })index.html
<div id="main">
    <mavon-editor v-model="value"/>
</div>首先在工程目录plugins 下新建 vue-mavon-editor.js  
import Vue from 'vue';
import mavonEditor from 'mavon-editor';
import 'mavon-editor/dist/css/index.css';
Vue.use(mavonEditor);
然后在nuxt.config.js 中添加plugins配置
plugins: [
  ...
    { src: '@/plugins/vue-mavon-editor', srr: false }
  ],最后一步在页面或者组件中引入
<template>
  <div class="mavonEditor">
    <no-ssr>
      <mavon-editor :toolbars="markdownOption" v-model="handbook"/>
    </no-ssr>
  </div>
</template>
<script>
export default {
  data() {
    return {
      markdownOption: {
        bold: true, // 粗体
        ... // 更多配置
      },
      handbook: "#### how to use mavonEditor in nuxt.js"
    };
  }
};
</script>
<style scoped>
.mavonEditor {
  width: 100%;
  height: 100%;
}
</style>| name 名称 | type 类型 | default 默认值 | describe 描述 | 
|---|---|---|---|
| value | String | 初始值 | |
| language | String | zh-CN | 语言选择,暂支持 zh-CN: 中文简体 , en: 英文 , fr: 法语, pt-BR: 葡萄牙语, ru: 俄语, de: 德语, ja: 日语 | 
| fontSize | String | 15px | 编辑区域文字大小 | 
| scrollStyle | Boolean | true | 开启滚动条样式(暂时仅支持chrome) | 
| boxShadow | Boolean | true | 开启边框阴影 | 
| subfield | Boolean | true | true: 双栏(编辑预览同屏), false: 单栏(编辑预览分屏) | 
| defaultOpen | String | edit: 默认展示编辑区域 , preview: 默认展示预览区域 , 其他 = edit | |
| placeholder | String | 开始编辑... | 输入框为空时默认提示文本 | 
| editable | Boolean | true | 是否允许编辑 | 
| codeStyle | String | code-github | markdown样式: 默认github, 可选配色方案 | 
| toolbarsFlag | Boolean | true | 工具栏是否显示 | 
| navigation | Boolean | false | 默认展示目录 | 
| shortCut | Boolean | true | 是否启用快捷键 | 
| autofocus | Boolean | true | 自动聚焦到文本框 | 
| ishljs | Boolean | true | 代码高亮 | 
| imageFilter | function | null | 图片过滤函数,参数为一个File Object,要求返回一个Boolean, true表示文件合法,false表示文件不合法  | 
| imageClick | function | null | 图片点击事件,默认为预览,可覆盖 | 
| tabSize | Number | \t | tab转化为几个空格,默认为\t | 
| toolbars | Object | 如下例 | 工具栏 | 
仅供个人学习参考/导航指引使用,具体请以第三方网站说明为准,本站不提供任何专业建议。如果地址失效或描述有误,请联系站长反馈~感谢您的理解与支持!
手机预览