前端

vue3渲染markdown格式数据

1.依赖

"marked": "^14.1.2",

2.示例

<template>
    <div class="main">
        <div v-html="renderedHtml"> </div>
    </div>
</template>
<script setup>
import { marked } from 'marked';
let markdonwContent= "";
const renderedHtml = ref(marked(markdonwContent));

//追加内容
const appendMarkDownContent = (content) => {
    markdonwContent+= content
    renderedHtml.value = marked(markdonwContent)
}
</script>

关于作者

程序员,软件工程师,java, golang, rust, c, python,vue, Springboot, mybatis, mysql,elasticsearch, docker, maven, gcc, linux, ubuntu, centos, axum,llm, paddlepaddle, onlyoffice,minio,银河麒麟,中科方德,rpm