Git地址:GitHub - bytedance/bytemd: ByteMD v1 repository
控制面板輸入
?npm install @bytemd/vue-next
下載成功后在src/main.ts中引用
import "bytemd/dist/index.css";
引入后保存,下面是一些插件,比如說我用到gmf和hightLight,下面就以這個舉例
npm install 你需要的插件
在我這里為:
npm install @bytemd/plugin-gfm
npm install @bytemd/plugin-highlight
下載成功后,可以新建一個vue模板
<template><Editor :value="value" :plugins="plugins" @change="handleChange" /> </template> <script setup lang="ts"> import gfm from "@bytemd/plugin-gfm"; import hightlight from "@bytemd/plugin-highlight"; import { Editor, Viewer } from "@bytemd/vue-next"; import { ref } from "vue"; //我使用的為gmf,highlight,可以根據自己的需要在plugins和import中引用 const plugins = [gfm(),hightlight(),// Add more plugins here ]; const value = ref(""); //輸入文本之后,觸發該事件,就可以在這里獲取到值 const handleChange = (v: string) => {value.value = v; }; </script><style scoped></style>
如果出現報錯提示:ESLint: Delete `?`(prettier/prettier)
參考文章
ESLint: Delete `?`(prettier/prettier)解決問題補充-CSDN博客