vue+showdown展示Markdown 文本

前言:

        vue+showdown展示Markdown 文本,资料整理

使用教程-vditor:

1、安装
npm install vditor --save
2、使用
<template>
    <div id="vditor" name="description" ></div>
</template>
<script>
    import Vditor from "vditor"
    import "vditor/dist/index.css"
export default {
    data(){
        return{
            contentEditor:""
        }
    },
    mounted(){
        this.contentEditor = new Vditor("vditor",{
            height:360,
            toolbarConfig:{
                pin:true
            },
            cache:{
                enable:false
            },
            after:()=>{
                this.contentEditor.setValue("hello,Vditor+Vue!")
            }
        })
    },
    methods:{
    }
}
</script>

使用教程-showdown:

https://gitcode.com/showdownjs/showdown/overviewicon-default.png?t=N7T8https://gitcode.com/showdownjs/showdown/overview

使用教程-markdown-it:展示 Markdown 文本:将获取到的 Markdown 文本转换为 HTML 并在页面中展示。

<template>
  <div>
    <div id="vditorContainer"></div>
    <div v-html="html"></div>
  </div>
</template>

<script>
import Vditor from 'vditor';
import MarkdownIt from 'markdown-it';

export default {
  data() {
    return {
      vditor: null,
      markdown: '',
      html: ''
    };
  },
  created() {
    this.vditor = new Vditor('vditorContainer');
  },
  methods: {
    getMarkdown() {
      this.markdown = this.vditor.getValue();
      const md = new MarkdownIt();
      this.html = md.render(this.markdown);
    }
  }
}
</script>

更多资料:

vue3内嵌Markdown编辑,并采用showdown展示,支持数学公式展示_vue3公式插件-CSDN博客

https://wenku.csdn.net/answer/dc86e4accd1f48fe85a75ca66856db89

相关推荐

  1. React展示Markdown|Vditor 踩坑

    2024-06-15 00:24:06       43 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-06-15 00:24:06       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-06-15 00:24:06       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-06-15 00:24:06       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-06-15 00:24:06       18 阅读

热门阅读

  1. ant-desigin-vue动态表头并填充数据

    2024-06-15 00:24:06       8 阅读
  2. DataCap 自定义 File 转换器

    2024-06-15 00:24:06       6 阅读
  3. 组合函数的实现

    2024-06-15 00:24:06       8 阅读
  4. CLIPSeg

    CLIPSeg

    2024-06-15 00:24:06      7 阅读
  5. 6.14--CSS

    2024-06-15 00:24:06       8 阅读
  6. kotlin 中的布尔

    2024-06-15 00:24:06       8 阅读
  7. 实体类的注解

    2024-06-15 00:24:06       5 阅读