A uni-app component library with uniapp API support
npm install animal-components一个专为 uniapp 设计的 Vue 3 组件库,内置 uniapp API 支持。
- 🚀 专为 uniapp 环境设计
- 📱 支持 H5、小程序、App 多端
- 🎨 现代化 UI 设计
- 📦 开箱即用
- 🔧 TypeScript 支持
- 📖 完整的文档和示例
``bash`
npm install animal-components
`javascript
// main.js
import { createSSRApp } from 'vue'
import AnimalComponents from 'animal-components'
export function createApp() {
const app = createSSRApp(App)
// 注册组件库
app.use(AnimalComponents)
return {
app
}
}
`
`vue
`
一个功能丰富的按钮组件,支持多种样式和尺寸。
#### Props
| 参数 | 类型 | 默认值 | 说明 |
|------|------|--------|------|
| text | string | '点击我' | 按钮文字 |
| type | 'primary' \| 'success' \| 'warning' \| 'error' | 'primary' | 按钮类型 |
| size | 'small' \| 'medium' \| 'large' | 'medium' | 按钮尺寸 |
| disabled | boolean | false | 是否禁用 |
#### Events
| 事件名 | 说明 | 回调参数 |
|--------|------|----------|
| click | 点击事件 | - |
#### 示例
`vue`
支持选择、预览、删除图片的上传组件。
#### Props
| 参数 | 类型 | 默认值 | 说明 |
|------|------|--------|------|
| maxCount | number | 1 | 最大选择图片数量 |
| sizeType | string[] | ['original', 'compressed'] | 图片尺寸类型 |
| sourceType | string[] | ['album', 'camera'] | 图片来源类型 |
| quality | number | 80 | 图片质量 |
#### Events
| 事件名 | 说明 | 回调参数 |
|--------|------|----------|
| success | 上传成功 | { url: string, tempFilePath: string } |
| fail | 上传失败 | error |
| delete | 删除图片 | - |
#### 示例
`vue
:quality="90"
@success="handleUploadSuccess"
@fail="handleUploadFail"
@delete="handleDelete"
/>
`
支持分页加载的数据列表组件。
#### Props
| 参数 | 类型 | 默认值 | 说明 |
|------|------|--------|------|
| title | string | '' | 列表标题 |
| apiUrl | string | - | 数据接口地址 |
| pageSize | number | 10 | 每页数据量 |
| autoLoad | boolean | true | 是否自动加载数据 |
#### Events
| 事件名 | 说明 | 回调参数 |
|--------|------|----------|
| itemClick | 列表项点击 | { item: any, index: number } |
| loadSuccess | 加载成功 | { data: any[], page: number, total: number } |
| loadError | 加载失败 | error |
#### 示例
`vue
title="商品列表"
api-url="https://api.example.com/products"
:page-size="20"
@item-click="handleItemClick"
@load-success="handleLoadSuccess"
>
`
`bash安装依赖
npm install
发布
`bash
构建项目
npm run build发布到 npm
npm publish
`注意事项
1. 此组件库专为 uniapp 环境设计,需要在 uniapp 项目中使用
2. 组件内部使用了 uniapp 的 API(如
uni.chooseImage、uni.request` 等)MIT
欢迎提交 Issue 和 Pull Request!