代码拉取完成,页面将自动刷新
PeasUI是基于Vue3+TypeScript的前端UI组件库
npm i peas-ui
// main.ts
import { createApp } from 'vue'
import PeasUI from 'peas-ui'
import "../node_modules/peas-ui/style.css"; //引入组件样式
import App from './App.vue'
const app = createApp(App)
app.use(PeasUI)
app.mount('#app')
<template>
<pe-button type="primary">primary</pe-button>
</template>
属性名 | 说明 | 类型 | 默认值 |
---|---|---|---|
type | 按钮类型 | string 'primary'/'success'/'info'/'warning'/'error' |
default |
round | 是否为圆角按钮 | boolean | false |
color | 自定义按钮颜色, 并自动计算 hover 和 active 触发后的颜色 |
string | - |
circle | 是否为圆形按钮 | boolean | false |
size | 尺寸 | string 'default'/'large'/'small' |
default |
prefix-icon | 头部图标 | Component | - |
suffix-icon | 尾部图标 | Component | - |
disabled | 按钮是否为禁用状态 | boolean | false |
loading | 是否为加载中状态 | boolean | false |
<template>
<pe-scrollbar height="200px">
<div style="height: 500px;background-color: #cccccc;"></div>
</pe-scrollbar>
</template>
属性名 | 说明 | 类型 | 默认值 |
---|---|---|---|
width | 组件宽度 | string | - |
max-width | 最大宽度 | string | - |
height | 组件高度 | string | 100% |
max-height | 最大高度 | string | - |
type | 滚动方向 | string 'both'/'horizontal'/'vertical'/'none' |
vertical |
事件名 | 说明 | 类型 |
---|---|---|
scroll | 当触发滚动事件时,返回滚动的距离 | Function |
<template>
<pe-input v-model="value" style="width: 200px;" placeholder="请输入内容" clearable />
</template>
<script setup lang="ts">
import { ref } from 'vue';
const value = ref<string>("")
</script>
属性名 | 说明 | 类型 | 默认值 |
---|---|---|---|
type | 类型 | string | text |
v-model | 绑定值 | string | - |
placeholder | 输入框占位文本 | string | - |
disabled | 是否禁用 | boolean | false |
readonly | 是否只读 | boolean | false |
maxlength | 同原生 maxlength 属性 | number | - |
show-word-count | 是否显示统计字数, 只在 type 为 'text' 的时候生效 | boolean | false |
size | 输入框尺寸 | string 'default'/'large'/'small' |
default |
clearable | 是否可以清空 | boolean | false |
autofocus | 原生属性,自动获取焦点 | boolean | false |
max | 原生 max 属性,设置最大值 | number | - |
min | 原生 min 属性,设置最小值 | number | - |
name | 等价于原生 input name 属性 | string | - |
prefix-icon | 前置图标 | Component | - |
suffix-icon | 后置图标 | Component | - |
事件名 | 说明 | 类型 |
---|---|---|
blur | 当选择器的输入框失去焦点时触发 | Function |
focus | 当选择器的输入框获得焦点时触发 | Function |
change | 仅当 modelValue 改变时,当输入框失去焦点或用户按Enter时触发 | Function |
input | 在 Input 值改变时触发 | Function |
clear | 在点击由 clearable 属性生成的清空按钮时触发 |
Function |
插槽名 | 说明 |
---|---|
prefix | 输入框头部内容 |
suffix | 输入框尾部内容 |
<template>
<pe-input-number v-model="value"></pe-input-number>
</template>
<script setup lang="ts">
import { ref } from "vue"
const value = ref<number>(0)
</script>
属性名 | 说明 | 类型 | 默认值 |
---|---|---|---|
v-model | 选中项绑定值 | number | - |
min | 设置计数器允许的最小值 | number | - |
max | 设置计数器允许的最大值 | number | - |
step | 计数器步长 | number | 1 |
size | 计数器尺寸 | string 'default'/'large'/'small' |
default |
readonly | 原生 readonly 属性,是否只读 | boolean | false |
disabled | 是否禁用状态 | boolean | false |
placeholder | 等价于原生 input placeholder 属性 | string | - |
controls-position | 控制按钮位置 | string 'default'/'right' |
default |
controls | 是否使用控制按钮 | boolean | true |
name | 等价于原生 input name 属性 | string | - |
reduce-icon | 自定义输入框按钮减少图标 | Component | - |
add-icon | 自定义输入框按钮增加图标 | Component | - |
名称 | 说明 | 类型 |
---|---|---|
blur | 当选择器的输入框失去焦点时触发 | Function |
focus | 当选择器的输入框获得焦点时触发 | Function |
change | 仅当 modelValue 改变时,当输入框失去焦点或用户按Enter时触发 | Function |
input | 在 Input 值改变时触发 | Function |
<template>
<pe-textarea v-model="value" :maxlength="10"></pe-textarea>
</template>
<script setup lang="ts">
import { ref } from "vue"
const value = ref<string>("")
</script>
属性名 | 说明 | 类型 | 默认值 |
---|---|---|---|
v-model | 选中项绑定值 | string | - |
name | 原生 textarea name 属性 | string | - |
id | 原生 textarea id 属性 | string | - |
cols | 原生 textarea cols 属性,文本域列数量 | number | 30 |
rows | 原生 textarea rows 属性,文本域行数量 | number | 3 |
disabled | 是否禁用 | boolean | false |
resize | 文本域拖拽方向 | string 'none'/'both'/'horizontal'/'vertical'/'block'/'inline' |
none |
maxlength | 最大输入字符数量 | number | - |
show-word-count | 是否显示字符数量 | boolean | false |
事件名 | 说明 | 类型 |
---|---|---|
blur | 当选择器的输入框失去焦点时触发 | Function |
focus | 当选择器的输入框获得焦点时触发 | Function |
change | 仅当 modelValue 改变时,当输入框失去焦点或用户按Enter时触发 | Function |
input | 在 Input 值改变时触发 | Function |
<template>
<pe-date-picker v-model="date"></pe-date-picker>
</template>
<script setup lang="ts">
import { ref } from "vue"
const date = ref<string | Date | number>()
</script>
属性名 | 说明 | 类型 | 默认 |
---|---|---|---|
v-model | 绑定值 | string/Date/number | - |
type | 绑定值类型 | string 'datestr'/'date'/'timestamp' |
datestr |
disabled | 是否禁用 | boolean | false |
size | 组件尺寸 | string 'default'/'large'/'small' |
default |
readonly | 是否只读 | boolean | false |
placeholder | 输入框占位文本 | string | - |
clearable | 是否可清空 | boolean | true |
name | 输入框name | string | - |
format | 显示在输入框中的格式 | 参照dayjs | YYYY-MM-DD |
value-format | 绑定值格式,只有type='datestr'才有效 | 参照dayjs | YYYY-MM-DD |
事件名 | 说明 | 类型 |
---|---|---|
change | 用户确认选定的值时触发 | Function |
blur | 在组件 Input 失去焦点时触发 | Function |
focus | 在组件 Input 获得焦点时触发 | Function |
<template>
<pe-time-picker v-model="date"></pe-time-picker>
</template>
<script setup lang="ts">
import { ref } from "vue"
const date = ref<string | number>()
</script>
属性名 | 说明 | 类型 | 默认 |
---|---|---|---|
v-model | 绑定值 | string/number | - |
disabled | 是否禁用 | boolean | false |
size | 组件尺寸 | 'default'/'large'/'small' | default |
readonly | 是否只读 | boolean | false |
placeholder | 输入框占位文本 | string | - |
clearable | 是否可清空 | boolean | true |
name | 输入框name | string | - |
id | 输入框id | string | - |
format | 输入框中的格式 | 参照dayjs | HH:mm:ss |
valueFormat | 绑定值格式 | 参照dayjs | HH:mm:ss |
事件名 | 说明 | 类型 |
---|---|---|
focus | 在组件 Input 获得焦点时触发 | Function |
blur | 在组件 Input 失去焦点时触发 | Function |
change | 用户确认选定的值时触发 | Function |
<template>
<pe-switch v-model="value1" active-value="1" inactive-value="2" active-text="1" inactive-text="2" :before-change="beforeChange1">
<template #active-action>
T
</template>
<template #inactive-action>
F
</template>
</pe-switch>
<pe-switch v-model="value2" active-value="1" inactive-value="2" active-text="1" inactive-text="2" :before-change="beforeChange2"></pe-switch>
</template>
<script setup lang="ts">
import { ref } from 'vue';
const value1 = ref<boolean | string | number>("1")
const value2 = ref<boolean | string | number>("1")
const beforeChange1 = () => {
return new Promise((resolve) => {
setTimeout(() => {
return resolve(true)
}, 1000)
})
}
const beforeChange2 = () => {
return new Promise((_, reject) => {
setTimeout(() => {
return reject(new Error('Error'))
}, 1000)
})
}
</script>
属性名 | 说明 | 类型 | 默认 |
---|---|---|---|
v-model | 绑定值,必须等于 active-value 或 inactive-value ,默认为 Boolean 类型 |
boolean/string/number | false |
disabled | 是否禁用 | boolean | false |
loading | 是否显示加载中 | boolean | false |
size | switch 的大小 | 'small'/'default'/'large' | default |
active-icon | switch 状态为 on 时所显示图标,设置此项会忽略 active-text | Component | - |
inactive-icon | switch 状态为 off 时所显示图标,设置此项会忽略 inactive-text | Component | - |
active-text | switch 打开时的文字描述 | string | - |
inactive-text | switch 的状态为 off 时的文字描述 | string | - |
active-value | switch 状态为 on 时的值 | boolean/string/number | true |
inactive-value | switch的状态为 off 时的值 | boolean/string/number | false |
name | switch 对应的 name 属性 | string | - |
before-change | switch 状态改变前的钩子, 返回 false 或者返回 Promise 且被 reject 则停止切换 | boolean/Function | true |
id | input 的 id | string | - |
tabindex | input 的 tabindex | string | - |
aria-label | 等价于原生 input aria-label 属性 | string | - |
事件名 | 说明 | 类型 |
---|---|---|
change | switch 状态发生变化时的回调函数 | Function |
名称 | 说明 |
---|---|
active-action | 自定义 active 行为 |
inactive-action | 自定义 inactive 行为 |
<template>
<pe-radio-group v-model="value" @change="change">
<pe-radio v-for="item in 5" :value="item">{{ item }}</pe-radio>
</pe-radio-group>
<pe-radio-group v-model="value" @change="change">
<pe-radio-button v-for="item in 5" :value="item">{{ item }}</pe-radio-button>
</pe-radio-group>
</template>
<script setup lang="ts">
import { ref } from "vue"
const value = ref<string | number | boolean>("")
const change = (val: string | number | boolean) => {
console.log(val);
}
</script>
属性名 | 说明 | 类型 | 默认 |
---|---|---|---|
v-model | 绑定值 | string/number/boolean | - |
size | 单选框尺寸 | 'default'/'small'/'large' | default |
disabled | 是否禁用 | boolean | false |
事件名 | 说明 | 类型 |
---|---|---|
change | 绑定值变化时触发的事件 | Function(value: string/number/boolean) => void |
插槽名 | 说明 | 子标签 |
---|---|---|
default | 自定义默认内容 | Radio / RadioButton |
属性名 | 说明 | 类型 | 默认 |
---|---|---|---|
value (required) | 单选框的值 | string/number/boolean | - |
label | 单选框的 label | string/number/boolean | - |
size | 单选框的尺寸 | 'default'/'small'/'large' | 'default' |
disabled | 是否禁用单选框 | boolean | false |
border | 是否显示边框 | boolean | false |
插槽名 | 说明 |
---|---|
default | 自定义默认内容 |
属性名 | 说明 | 类型 | 默认 |
---|---|---|---|
value (required) | 单选框的值 | string/number/boolean | - |
label | 单选框的 label | string/number/boolean | - |
disabled | 是否禁用单选框 | boolean | false |
插槽名 | 说明 |
---|---|
default | 默认插槽内容 |
<template>
<pe-checkbox-group v-model="value" @change="change">
<pe-checkbox v-for="item in 5" :value="item">{{ item }}</pe-checkbox>
</pe-checkbox-group>
<pe-checkbox-group v-model="value" @change="change">
<pe-checkbox-button v-for="item in 5" :value="item">{{ item }}</pe-checkbox-button>
</pe-checkbox-group>
</template>
<script setup lang="ts">
import { ref } from "vue"
const value = ref<string[] | number[]>([])
const change = (val: string[] | number[]) => {
console.log(val);
}
</script>
属性名 | 说明 | 类型 | 默认 |
---|---|---|---|
v-model | 绑定值 | string[]/number[] | [] |
size | 多选框组尺寸 | 'default'/'small'/'large' | default |
disabled | 是否禁用 | boolean | false |
min | 可被勾选的 checkbox 的最小数量 | number | - |
max | 可被勾选的 checkbox 的最大数量 | number | - |
事件名 | 说明 | 类型 |
---|---|---|
change | 当绑定值变化时触发的事件 | Function(value: string[]/number[]) => void |
插槽名 | 说明 | 子标签 |
---|---|---|
default | 自定义默认内容 | Checkbox / Checkbox-button |
属性名 | 说明 | 类型 | 默认 |
---|---|---|---|
v-model | 选中项绑定值 | boolean | false |
value (required) | 选中状态的值(只有在checkbox-group或者绑定对象类型为array时有效) | string/number | - |
label | 选中状态的值,只有在绑定对象类型为 array 时有效。 | string/number | - |
disabled | 是否禁用 | boolean | false |
size | Checkbox 的尺寸 | 'default'/'small'/'large' | default |
border | 是否显示边框 | boolean | false |
name | 原生 name 属性 | string | - |
indeterminate | 设置不确定状态,仅负责样式控制 | boolean | false |
事件名 | 说明 | 类型 |
---|---|---|
change | 当绑定值变化时触发的事件 | Function(value: boolean) => void |
插槽名 | 说明 |
---|---|
default | 自定义默认内容 |
属性名 | 说明 | 类型 | 默认 |
---|---|---|---|
v-model | 选中项绑定值 | boolean | false |
value (required) | 选中状态的值(只有在checkbox-group或者绑定对象类型为array时有效) | string/number | - |
label | 选中状态的值,只有在绑定对象类型为 array 时有效。 | string/number | - |
disabled | 是否禁用 | boolean | false |
name | 原生 name 属性 | string | - |
事件名 | 说明 | 类型 |
---|---|---|
change | 当绑定值变化时触发的事件 | Function(value: boolean) => void |
插槽名 | 说明 |
---|---|
default | 自定义默认内容 |
<template>
<pe-avatar src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"></pe-avatar>
</template>
属性名 | 说明 | 类型 | 默认 |
---|---|---|---|
icon | 设置 Avatar 的图标类型,具体参考 Icon 组件 | Component/string | - |
size | Avatar 大小 | 'small'/'default'/'large'/number | default |
shape | Avatar 形状 | 'circle'/'square' | circle |
src | Avatar 图片的源地址 | string | - |
src-set | 图片 Avatar 的原生 srcset 属性 | string | - |
alt | 图片 Avatar 的原生 alt 属性 | string | - |
fit | 当展示类型为图片的时候,设置图片如何适应容器 | 'fill'/'contain'/'cover'/'none'/'scale-down' | cover |
属性名 | 说明 | 类型 | 默认 |
---|---|---|---|
value | 显示值 | string/number | '' |
max | 最大值,超过最大值会显示 {max}+。 只有当 value 是数字类型时起作用。 | number | - |
is-dot | 是否显示小圆点 | boolean | false |
hidden | 是否隐藏 Badge。 | boolean | false |
show-zero | 值为零时是否显示 Badge | boolean | false |
color | 背景色 | string | #ff0000 |
offset | badge 的偏移量 | [string, string] | ['50%', '-50%'] |
badge-style | 自定义 badge 样式 | CSSProperties | - |
badge-class | 自定义 badge 类名 | string | - |
插槽名 | 说明 |
---|---|
default | 自定义默认内容 |
<template>
<pe-card header="title" shadow="hover"></pe-card>
</template>
属性名 | 说明 | 类型 | 默认 |
---|---|---|---|
header | 卡片的标题 你既可以通过设置 header 来修改标题,也可以通过 slot#header 传入 DOM 节点 | string | - |
footer | 卡片页脚。 你既可以通过设置 footer 来修改卡片底部内容,也可以通过 slot#footer 传入 DOM 节点 | string | - |
body-style | body 的 CSS 样式 | CSSProperties | - |
body-class | body 的自定义类名 | string | - |
shadow | 卡片阴影显示时机 | 'always'/'never'/'hover' | always |
插槽名 | 说明 |
---|---|
header | 卡片标题内容 |
default | 自定义默认内容 |
footer | 卡片页脚内容 |
<template>
<pe-calendar v-model="date" title="Title" @change="change"></pe-calendar>
</template>
<script setup lang="ts">
import { ref } from 'vue';
const date = ref<Date>(new Date())
const change = (val: Date) => {
console.log(val);
}
</script>
属性名 | 说明 | 类型 | 默认 |
---|---|---|---|
v-model | 选中项绑定值 | Date | - |
title | 标题 | string | - |
事件名 | 说明 | 类型 |
---|---|---|
change | 点击日期触发函数 | Function |
插槽名 | 说明 |
---|---|
title | 标题内容 |
cell | 可选值有date,表示当前日历框中的日期 |
<template>
<pe-progress :percentage="percent" stroke-width="24" :indeterminate="false" type="line" striped striped-flow></pe-progress>
<pe-button @click="onClick">按钮</pe-button>
</template>
<script setup lang="ts">
import { ref } from "vue"
const percent = ref<number>(0)
const onClick = () => {
percent.value = Math.floor(Math.random() * 100)
}
</script>
属性名 | 说明 | 类型 | 默认 |
---|---|---|---|
percentage | 百分比 | number | 0 |
type | 进度条类型 | 'line'/'circle'/'dashboard' | line |
stroke-width | 进度条的宽度 | number | 6 |
text-inside | 进度条显示文字内置在进度条内(仅 type 为 'line' 时可用) | boolean | false |
status | 进度条当前状态 | 'primary'/'success'/'exception'/'warning' | primary |
indeterminate | 是否为动画进度条 | boolean | false |
duration | 控制动画进度条速度和条纹进度条流动速度 | number | 3 |
color | 进度条背景色 (会覆盖 status 状态颜色) | string | - |
show-text | 是否显示进度条文字内容 | boolean | true |
width | 环形进度条画布宽度(只在 type 为 circle 或 dashboard 时可用) | number | 126 |
striped | 在进度条上增加条纹 | boolean | false |
striped-flow | 让进度条上的条纹流动起来 | boolean | false |
插槽名 | 说明 |
---|---|
default | 自定义内容 |
<template>
<pe-button @click="show = true">显示 Dialog</pe-button>
<pe-dialog v-model="show"></pe-dialog>
</template>
<script setup lang="ts">
import { ref } from "vue"
const show = ref<boolean>(false)
</script>
属性名 | 说明 | 类型 | 默认 |
---|---|---|---|
v-model | 是否显示 Dialog | boolean | - |
title | 弹出框标题 | string | Title |
width | 对话框的宽度,默认值为 50% | string/number | 50% |
top | 弹出框与屏幕顶部的距离 | string | 15vh |
modalClass | 遮罩的自定义类名 | string | - |
close-on-click-modal | 是否可以通过点击 modal 关闭 Dialog | boolean | true |
show-close | 是否显示关闭按钮 | boolean | true |
modal | 是否需要遮罩层 | boolean | true |
draggable | 是否可拖拽 | boolean | false |
事件名 | 说明 | 类型 |
---|---|---|
open | 开启的回调 | Function |
close | 关闭的回调 | Function |
插槽名 | 说明 |
---|---|
header | 对话框标题的内容;会替换标题部分,但不会移除关闭按钮。 |
default | Dialog 的内容 |
<template>
<pe-alert></pe-alert>
</template>
属性名 | 说明 | 类型 | 默认值 |
---|---|---|---|
title | Alert 标题 | string | '' |
type | Alert 类型 | 'success'/'warning'/'info'/'error' | success |
description | 描述性文本 | string | - |
closable | 是否可以关闭 | boolean | true |
center | 文字是否居中 | boolean | false |
close-text | 自定义关闭按钮文本 | string | - |
show-icon | 是否显示类型图标 | boolean | false |
effect | 主题样式 | 'light'/'dark' | light |
事件名 | 说明 | 类型 |
---|---|---|
close | 关闭 Alert 时触发的事件 | Function |
插槽名 | 说明 |
---|---|
title | 标题的内容 |
default | Alert 内容描述 |
<template>
<button @click="show = true">显示</button>
<pe-drawer v-model="show" direction="left" title="Title">内容</pe-drawer>
</template>
<script setup lang="ts">
import { ref } from "vue"
const show = ref<boolean>(false)
</script>
属性名 | 说明 | 类型 | 默认值 |
---|---|---|---|
v-model | 是否显示 Drawer | booledn | false |
close-on-click-modal | 是否可以通过点击 modal 关闭 Drawer | boolean | true |
direction | Drawer 打开的方向 | 'right'/'left'/'top'/'bottom' | right |
show-close | 是否显示关闭按钮 | boolean | true |
size | Drawer 窗体的大小, 当使用 number 类型时, 以像素为单位 | number/string | 30% |
title | Drawer 的标题,也可通过具名 slot (见下表)传入 | string | - |
with-header | 控制是否显示 header 栏, 默认为 true, 当此项为 false 时, title attribute 和 header slot 均不生效 | boolean | true |
modal-class | 遮罩层的自定义类名 | string | - |
事件名 | 说明 | 类型 |
---|---|---|
open | Drawer 打开的回调 | Function |
opened | Drawer 打开动画结束时的回调 | Function |
close | Drawer 关闭的回调 | Function |
closed | Drawer 关闭动画结束时的回调 | Function |
插槽名 | 说明 |
---|---|
default | Drawer 的内容 |
header | Drawer 标题的内容;会替换标题部分,但不会移除关闭按钮。 |
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。