v-md-editor使用

参考Vue3使用v-md-editor md展示修改markdown(md)文档_v-md-editor读取md文件-CSDN博客

1.导入   npm install @kangc/v-md-editor@next (npm管理)

2.在mian.js 中引入

// 富文本 v-md-editor 导入
import VMdEditor from "@kangc/v-md-editor";
import "@kangc/v-md-editor/lib/style/base-editor.css";
import githubTheme from "@kangc/v-md-editor/lib/theme/github.js";
import "@kangc/v-md-editor/lib/theme/style/github.css";
// highlightjs
import hljs from "highlight.js";
VMdEditor.use(githubTheme, {
  Hljs: hljs,
});
createApp(App).use(router).use(Antd).use(VMdEditor).mount("#app");

3.编辑器的使用(TODO)

4.富文本格式(md格式)显示

//代码块引入
import VMdTextareaEditor from "@kangc/v-md-editor";
//当做组件直接使用
<VMdTextareaEditor v-model="item.content" :mode="`preview`" />

效果图:

可能碰到的报错:(vue3+typeScript)

参考:在 vue3 中使用报错? | v-md-editor (gitee.io)

错误示例:Could not find a declaration file for module '@kangc/v-md-editor/lib/theme/vuepress.js'.

解决方法:

// src/shims.d.ts
declare module '@kangc/v-md-editor/lib/theme/vuepress.js';

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值