首页 > 其他分享 >从零用VitePress搭建博客教程(6) -– 第三方组件库的使用和VitePress搭建组件库文档

从零用VitePress搭建博客教程(6) -– 第三方组件库的使用和VitePress搭建组件库文档

时间:2023-10-23 10:13:29浏览次数:34  
标签:element plus VitePress 按钮 组件 文档 搭建

接上一节:从零用VitePress搭建博客教程(5) - 如何自定义页面模板、给页面添加独有的className和使页面标题变成侧边目录?

九、第三方组件库的使用

我们经常看见UI组件库的文档,这里我们就用element-plus第三方组件库为例子,搭建组件库文档

examples:作为组件库示例目录,我们以Button组件使用为例

1、安装element-plus

pnpm install element-plus

2、引入element-plus

安装完成后,在theme/index.js引入element-plus相关文件

import DefaultTheme from "vitepress/theme";
 
import ElementPlus from "element-plus";
import "element-plus/dist/index.css";
 
export default {
  ...DefaultTheme,
  NotFound: () => "404", // <- this is a Vue 3 functional component
  enhanceApp({ app, router, siteData }) {
    // app is the Vue 3 app instance from createApp()
    // router is VitePress' custom router (see `lib/app/router.js`)
    // siteData is a ref of current site-level metadata.
    app.use(ElementPlus);
  },
};

3、编写button.md文档

# Button 按钮
 
## 基础用法
 
<div class="ui-button">
  <el-button type="primary">主要按钮</el-button>
  <el-button type="success">绿色按钮</el-button>
  <el-button type="info">灰色按钮</el-button>
  <el-button type="warning">黄色按钮</el-button>
  <el-button type="danger">红色按钮</el-button>
</div>
 
<details>
  <summary>查看代码</summary>
 
``` vue
<template>
  <el-button type="primary">主要按钮</el-button>
  <el-button type="success">绿色按钮</el-button>
  <el-button type="info">灰色按钮</el-button>
  <el-button type="warning">黄色按钮</el-button>
  <el-button type="danger">红色按钮</el-button>
</template>
```
 
</details>
 
 
### plain用法
 
<div class="ui-button">
  <el-button type="primary" plain>主要按钮</el-button>
  <el-button type="success" plain>绿色按钮</el-button>
  <el-button type="info" plain>灰色按钮</el-button>
  <el-button type="warning" plain>黄色按钮</el-button>
  <el-button type="danger" plain>红色按钮</el-button>
</div>
 
::: details CODE
 
``` vue
<el-button type="primary" plain>主要按钮</el-button>
<el-button type="success" plain>绿色按钮</el-button>
<el-button type="info" plain>灰色按钮</el-button>
<el-button type="warning" plain>黄色按钮</el-button>
<el-button type="danger" plain>红色按钮</el-button>
```
:::

这里用到html5的details和summary标签,不了解的话可以去搜索看下。

然后配置一个“组件使用”的头部导航,效果如下:

在线预览效果:https://msyuan.github.io/vitePress-project/examples/button.html

github地址:https://github.com/msyuan/vitePress-project

 原文地址:VitePress最新版本使用-第三方组件库的使用和搭建组件库文档

 

标签:element,plus,VitePress,按钮,组件,文档,搭建
From: https://www.cnblogs.com/myboogle/p/17781780.html

相关文章

  • ServerLess学习笔记-Fnproject搭建
    ServerLess学习笔记-搭建FnProject介绍官方文档:https://fnproject.io/tutorials/Fn是一个事件驱动的开源功能即服务FaaS计算平台,您可以在任何地方运行,它的一些主要特点开源原生Docker:使用任何Docker容器作为你的函数支持所有语言随处运行公有云、私有云和混合云......
  • ServerLess学习笔记-搭建FN示例
    ServerLess学习笔记-搭建FnProject示例初始化函数目录#初始化fn_demo1[root@VM-24-9-centosserverless]#fninit--runtimepythonfn_demo1Creatingfunctionat:./fn_demo1UnabletogetlatestFDKversion,usingdefaultFunctionboilerplategenerated.func.yam......
  • Vue.js框架:vue3版本父子组件之间的传值和事件触发
    一、子组件使用vue3官方提供的setup语法糖中给出的defineEmits、defineProps来定义父子间的传参值和关联方法(useContext在3.2版本之后已去除)。<scriptsetuplang="ts">import{defineProps,defineEmits}from'vue'constemitEvents=defineEmits(['so......
  • 两台实体机器4个虚拟机节点的Hadoop集群搭建(Ubuntu版)
    安装UbuntuLinux元信息两台机器,每台机器两台UbuntuUbuntu版本:ubuntu-22.04.3-desktop-amd64.iso处理器数量2,每个处理器的核心数量2,总处理器核心数量4单个虚拟机内存8192MB(8G),最大磁盘大小30G参考链接清华大学开源软件镜像站https://mirrors.tuna.tsinghua.edu.cn/ubunt......
  • 65.初始化vitepress项目
    1.电脑本地需要安装node16+版本2.电脑本地安装pnpm3.本地创建一个文件夹,用于存放该项目,如:F:\资料整合\编程资料\编程项目\网页\sfisadmin\vitepress4.进入该文件夹5.初始化node工程:pnpminit 6.安装vitepresspnpmadd-Dvitepress 7.初始化vietepresspnpmexecvit......
  • npm安装datav-vue3(一个大屏边框和装饰组件)后报错Failed to resolve entry for packa
    原因:个人认为应该是npm上的版本比较低,因为弄好后装饰只能用到第8个,后面的都没有,查看package.json里它的版本为^0.0.0-test.1672506674342,也就是说还没有正式版,在官方的说明里也有体现---[目前还处于Alpha阶段,所有的API及Props都可能在后续迭代中发生变化]介绍|DataV......
  • #yyds干货盘点#Linux系统的web管理工具——webmin搭建
    一、webmin介绍Webmin是目前功能最强大的基于Web的Unix系统管理工具。管理员通过浏览器访问Webmin的各种管理功能并完成相应的管理动作。目前Webmin支持绝大多数的Unix系统,这些系统除了各种版本的linux以外还包括:AIX、HPUX、Solaris、Unixware、Irix和FreeBSD等。二、添加webmin的y......
  • 在安卓平板上搭建 webdav 服务
    早上醒来,脑子里又冒出来要搭建一个webdav服务以便尝试各种非云服务模式的笔记客户端的念头。于是任性的尝试起来。在自己的华为matepad安卓平板上进行的。搭建Linux模拟环境从f-droid应用市场中安装termuxapp。termux带包管理,而且有非常多的应用可用,甚至nodejs。......
  • docker搭建网安靶场教程
    Docker拉取靶场环境docker是一个很好用的容器服务,它相当于在你的虚拟机中生成无数个容器,可以供开发人员使用,假设一个环境,如果你想搭建网安靶场环境供自己练习,那么常规情况下你就要去VM里开环境自己搭建,这样是非常慢的,不如使用docker服务,而且还可以上网上拉取自己想要的镜像,同样......
  • 从零用VitePress搭建博客教程(5) - 如何自定义页面模板、给页面添加独有的className和
    接上一节:从零用VitePress搭建博客教程(4)–如何自定义首页布局和主题样式修改?上一节其实我们也简单说了自定义页面模板,这一节更加详细一点说明,开始之前我们要知道在vitePress中,.md的文件是可以直接编写vue的代码的。比如我们现在来自定义一个前端网址导航页面八、自定义一些......