推荐好用的vue插件02 v-md-editor富文本编辑器

一、介绍

v-md-editor 是基于 Vue 开发的 markdown 编辑器组件

二、安装与注册

即支持vue2.0的项目也支持vue3.0的项目,不过两种版本的安装版本不同

- [Demo](https://code-farmer-i.github.io/vue-markdown-editor/examples/base-editor.html)
- [Documentation](https://code-farmer-i.github.io/vue-markdown-editor/)
- [中文文档](https://code-farmer-i.github.io/vue-markdown-editor/zh/)
- [国内文档镜像](http://ckang_1229.gitee.io/vue-markdown-editor/zh/)
- [Changelog](https://code-farmer-i.github.io/vue-markdown-editor/changelog.html)

这里有官网的链接地址,可以查看两种版本的注册方式,介绍一下对于quasar2.0的项目如何进行注册:


import VueMarkdownEditor from "@kangc/v-md-editor";
import "@kangc/v-md-editor/lib/style/base-editor.css";
import vuepressTheme from '@kangc/v-md-editor/lib/theme/vuepress.js';
import '@kangc/v-md-editor/lib/theme/style/vuepress.css';

import { boot } from 'quasar/wrappers';
import Prism from 'prismjs';

export default boot(({ app }) => {
  VueMarkdownEditor.use(vuepressTheme, {
    Prism,
  });
  //挂载到vue中
  app.use(VueMarkdownEditor);
});

三、在组件内的使用

<template>
  <div class="" style="margin: 10px; height: calc(100vh - 105px)">
    <v-md-editor v-model="data.content"    height="100%"></v-md-editor>
  </div>
</template>

四、常用API属性

 1.text  String类型

需要解析的markdown 字符串(只有预览组件支持该属性)

2.v-model  String类型

双向绑定(只有编辑组件支持该属性)

3.mode  String类型,默认值editable

模式(可选值:edit纯编辑模式、 editable编辑与预览模式、preview纯预览模式)

4.height   String类型

正常模式下编辑器的高度

5.default-show-toc   boolean类型,默认值false

是否默认显示目录导航

6.default-fullscreen   boolean类型,默认值false

是否默认开启全屏

7.left-toolbar   类型:string

  • 默认值: undo redo clear | h bold italic strikethrough quote | ul ol table hr | link image code | save  

 左侧工具栏

名称说明
undo撤销
redo重做
clear清空
h标题
bold粗体
italic斜体
strikethrough中划线
quote引用
ul无序列表
ol有序列表
table表格
hr分割线
link链接
image插入图片
code代码块
save保存,点击后触发save事件

 8.right-toolbar   类型:String

默认值: preview toc sync-scroll fullscreen

右侧工具栏

名称说明
preview预览
toc目录导航
sync-scroll同步滚动
fullscreen全屏

  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值