vite-plugin-md-vue
v1.0.1
Published
A vite plugin
Downloads
7
Readme
vite-plugin-md-vue
将vue文件同路径下的md文件转换成vue组件
Install
npm i vite-plugin-md-vue -D
使用
在vite.config 中引入插件:
import MarkDownVue from 'vite-plugin-md-vue';
vite.config:
plugins: [...其他配置,MarkDownVue()];
vue文件中使用:
<script>
import g-markdown from './test.md?raw';
</script>
<template>
<g-markdown file="vue文件同路径下md文件名称(包含后缀) 例:test.md" />
</template>
可能遇到的问题
在引入markdown资源时可能需要加上 ?raw 后缀来标识作为字符串引入(如上) Vite文档
配置项:
类型不存在则使用默认 div
tag: "a" | "div" | "span" | "header" | "section" | "footer" | "main" | "nav"
wrapClass: 添加至外层容器的类名 默认不添加
示例:
MarkDownVue({
tag:'section',
wrapClass:'class_test'
})