安装指南
环境要求
- Node.js >= 16
- npm >= 7 或 yarn >= 1.22 或 pnpm >= 6
安装方式
使用 npm
bash
npm install @weitutech/by-components-v3使用 yarn
bash
yarn add @weitutech/by-components-v3使用 pnpm
bash
pnpm add @weitutech/by-components-v3引入方式
完整引入
js
import { createApp } from 'vue'
import ByComponentsV3 from '@weitutech/by-components-v3'
import 'by-components-v3/dist/style.css'
const app = createApp(App)
app.use(ByComponentsV3)
app.mount('#app')按需引入
js
import { createApp } from 'vue'
import { ByForm, ByTable, ByPager } from '@weitutech/by-components-v3'
import 'by-components-v3/dist/style.css'
const app = createApp(App)
app.component('ByForm', ByForm)
app.component('ByTable', ByTable)
app.component('ByPager', ByPager)
app.mount('#app')依赖说明
ByComponents V3 依赖以下第三方库:
- Vue 3 - 核心框架
- Element Plus - UI 组件库
- vxe-table - 表格组件
- vxe-pc-ui - PC 端 UI 组件
- moment - 日期处理库
这些依赖会在安装时自动安装。
样式引入
确保在项目中引入样式文件:
js
import 'by-components-v3/dist/style.css'如果使用按需引入,也需要引入样式文件。
TypeScript 支持
ByComponents V3 提供完整的 TypeScript 类型定义,无需额外配置。
版本兼容性
| ByComponents V3 | Vue | Element Plus | vxe-table |
|---|---|---|---|
| 1.x.x | ^3.5.0 | ^2.9.0 | ^4.10.0 |
常见问题
Q: 安装后组件无法使用?
A: 确保已经正确引入样式文件,并且 Vue 版本为 3.x。
Q: TypeScript 报错?
A: 确保 TypeScript 版本 >= 4.5,并且正确配置了 Vue 3 的类型支持。
Q: 样式不生效?
A: 检查是否正确引入了 by-components-v3/dist/style.css 文件。
