meraid的memo

2023-05-16

首先安装mermaid和antd,即可复制下面代码在react中实现demo效果

import React from 'react'
import {Input} from 'antd'
import mermaid from "mermaid";
const {TextArea} =Input

export default function Mermaid() {
const [text,setText] = React.useState(`    
sequenceDiagram
    Alice->>John: Hello John, how are you?
    John-->>Alice: Great!
    Alice-)John: See you later!
`)

async function textChange (e){
   setText(e.target.value)
   const element = document.querySelector('#graphDiv');
    const { svg } = await mermaid.render('mermaid', e.target.value);
    element.innerHTML = svg
    console.log(svg);
    await mermaid.run();
};
  React.useEffect(()=>{
     mermaid.contentLoaded()
  },[])
  return (
    <div >
      <TextArea 
      autoSize
      value={text}
      onChange={textChange}/>
    <pre  className="mermaid" id="graphDiv" >
            {text}
    </pre>
    </div>
  );
}

效果展示:输入即可生产时序图

文档:https://mermaid.js.org/syntax/examples.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

meraid的memo 的相关文章

随机推荐

  • linux命令行——linux快速搜索历史命令

    一 需求描述 在执行命令时 xff0c 对于已经输入的历史命令 xff0c 可以通过关上下键进行翻找 xff0c 如果是最近几条 xff0c 很容易找到 xff0c 如果是很久之前的命令 xff0c 依旧使用上下键查找就会力不从心 二 解决
  • 如何用六步教会你使用python爬虫爬取数据

    前言 xff1a 用python的爬虫爬取数据真的很简单 xff0c 只要掌握这六步就好 xff0c 也不复杂 以前还以为爬虫很难 xff0c 结果一上手 xff0c 从初学到把东西爬下来 xff0c 一个小时都不到就解决了 python爬
  • react实现点击复制

    1 使用浏览器提供的document execCommand 39 copy 39 2 使用copy to clipboard库 document execCommand 34 copy 34 1 document execCommand封
  • zustand

    最近工作中需要用到zustand xff0c 先记录一下学到的demo 安装 xff1a npm install zustand 公共文件store引入 import create from 39 zustand 39 const useS
  • antd获取表单的所有数据

    当我们使用antd的组件的form 表单时 xff0c 数据一般在form中的onFinish 61 onFinish 方法上可以拿到 const Demo 61 61 gt const onFinish 61 values any 61
  • antd使用阿里巴巴矢量图标

    最近需要在antd引入中阿里矢量图标 xff0c 看到几个关于antd使用iconfont的回答 xff0c 其中关于Icon的引入 xff0c 都是写的从antd引入 xff08 不可用 xff09 旧版本 xff1a import Ic
  • antd表单赋值,回显表格数据

    使用 antd 做表格回显数据时 xff0c 会看到文档有写 xff1a 所以我们可以 1 定义hooks const form 61 Form useForm 2 在触发事件中使用 xff0c 以打开模态框赋值为例 const showM
  • react反向代理配置

    官网 xff1a https create react app dev docs proxying api requests in development 安装 npm install http proxy middleware save
  • js立即执行函数写法

    优点 xff1a 1 立即执行 xff0c 不用担心临时变量污染全局变量 xff0c 减少命名 2 方便封装 写法 xff1a function name params console log params 打印 1 1 function
  • uboot的环境变量-2.9.uboot源码分析5-朱有鹏-专题视频课程

    uboot的环境变量 2 9 uboot源码分析5 3347人已学习 课程介绍 本课程为uboot学习的第9部分 xff0c 主要讲解uboot的环境变量的实现原理和环境变量在内存中 SD卡中的存储方法 结合环境变量相关的几个命令的代码分析
  • 输出什么呢?

    let normaLize 61 function params let arr 61 params split g filter v 61 gt v let result 61 let obj 61 result while key 61
  • Pormise

    Promise是一个构造函数 三种状态 xff1a pending xff08 进行中 xff09 fulfilled xff08 已成功 xff09 和rejected xff08 已失败 xff09 xff0c fulfilled和re
  • js删除对象的某个属性

    第一种 xff1a delete const obj 61 name 39 章三 39 age 18 删除age这个属性 delete obj age console log obj name 39 章三 39 第二种 xff08 ES6
  • moment时区转换

    moment js 时区转换 根据本地时区 moment 34 2022 05 31T16 00 00 000Z 34 format 39 YYYY MM DD 39 39 2022 06 01 39
  • TypeScript

    安装 npm install g typescript 安装完成后 xff0c 在控制台运行如下命令 xff0c 检查安装是否成功 3 x xff1a tsc V vscode自动编译 1 生成配置文件tsconfig json tsc i
  • 数组中第一个不重复的值

    var firstUniqChar 61 function s const arr 61 countBy s for const i k of Array from s entries if arr k 61 61 61 1 return
  • JS中数组转字符串,字符串转数组方法合集

    一 字符串转数组 xff1a 1 Array split const str 61 39 hello 39 str split 39 39 39 h 39 39 e 39 39 l 39 39 l 39 39 o 39 const str2
  • React和Vue 父组件调用子组件的方法

    react 父组件 xff1a 使用createRef和useRef都可以 import useRef from 39 react 39 let ChildRef 61 useRef function handleOnClick Child
  • Utils

    平级数组转为树状 const dataTree 61 id 1 name 39 总公司 39 parentId 0 id 2 name 39 深圳分公司 39 parentId 1 id 3 name 39 北京分公司 39 parentI
  • meraid的memo

    首先安装mermaid和antd xff0c 即可复制下面代码在react中实现demo效果 import React from 39 react 39 import Input from 39 antd 39 import mermaid