跳到主要内容

反馈组件

反馈组件用于向用户提供操作反馈、状态提示和交互响应。

Alert - 警告提示

用于页面中展示重要的提示信息。

基本用法

Alert() {
// 警告内容
}

属性列表

属性接受类型默认值说明
typestring"info"警告类型
titlestring""警告标题
messagestring""警告内容
showIconbooltrue是否显示图标
closableboolfalse是否可关闭
closeTextstring"关闭"关闭按钮文字
onClosefuncnull关闭事件
widthstring, int, singlef"auto"宽度
heightstring, int, singlef"auto"高度
paddingstring, int, singlef16内边距
marginstring, int, singlef0外边距
backgroundColorstring"transparent"背景颜色
borderRadiusstring, int, singlef4圆角
borderstring"1px solid"边框

类型值

说明
"success"成功
"info"信息
"warning"警告
"error"错误

示例

// 成功提示
Alert()
.type("success")
.title("操作成功")
.message("您的操作已成功完成")
.showIcon(true)
.closable(true)

// 错误提示
Alert()
.type("error")
.title("操作失败")
.message("请检查输入信息后重试")
.showIcon(true)
.onClose(() => {
// 关闭处理
})

Message - 消息提示

用于显示全局提示信息。

基本用法

Message() {
// 消息内容
}

属性列表

属性接受类型默认值说明
typestring"info"消息类型
contentstring""消息内容
durationint3000显示时长(毫秒)
showIconbooltrue是否显示图标
closableboolfalse是否可关闭
onClosefuncnull关闭事件
positionstring"top"显示位置
widthstring, int, singlef"auto"宽度
heightstring, int, singlef"auto"高度
paddingstring, int, singlef12内边距
marginstring, int, singlef0外边距
backgroundColorstring"#ffffff"背景颜色
colorstring"#333333"文字颜色
borderRadiusstring, int, singlef4圆角
boxShadowstring"0 2px 8px rgba(0,0,0,0.15)"阴影

位置值

说明
"top"顶部
"topLeft"左上
"topRight"右上
"bottom"底部
"bottomLeft"左下
"bottomRight"右下

示例

// 成功消息
Message()
.type("success")
.content("保存成功")
.duration(2000)
.position("top")

// 错误消息
Message()
.type("error")
.content("网络连接失败")
.duration(5000)
.closable(true)
.onClose(() => {
// 关闭处理
})

Notification - 通知

用于显示通知信息,支持更多自定义内容。

基本用法

Notification() {
// 通知内容
}

属性列表

属性接受类型默认值说明
typestring"info"通知类型
titlestring""通知标题
descriptionstring""通知描述
durationint4500显示时长(毫秒)
showIconbooltrue是否显示图标
closablebooltrue是否可关闭
onClosefuncnull关闭事件
onClickfuncnull点击事件
positionstring"topRight"显示位置
widthstring, int, singlef320宽度
heightstring, int, singlef"auto"高度
paddingstring, int, singlef16内边距
marginstring, int, singlef0外边距
backgroundColorstring"#ffffff"背景颜色
colorstring"#333333"文字颜色
borderRadiusstring, int, singlef6圆角
boxShadowstring"0 4px 12px rgba(0,0,0,0.15)"阴影

示例

// 成功通知
Notification()
.type("success")
.title("上传完成")
.description("文件已成功上传到服务器")
.duration(3000)
.position("topRight")

// 带操作的通知
Notification()
.type("info")
.title("新消息")
.description("您有3条未读消息")
.duration(0)
.closable(true)
.onClick(() => {
// 跳转到消息页面
})

Toast - 轻提示

用于显示轻量级的提示信息。

基本用法

Toast() {
// 提示内容
}

属性列表

属性接受类型默认值说明
typestring"info"提示类型
contentstring""提示内容
durationint2000显示时长(毫秒)
positionstring"center"显示位置
maskboolfalse是否显示遮罩
widthstring, int, singlef"auto"宽度
heightstring, int, singlef"auto"高度
paddingstring, int, singlef12内边距
marginstring, int, singlef0外边距
backgroundColorstring"rgba(0,0,0,0.7)"背景颜色
colorstring"#ffffff"文字颜色
borderRadiusstring, int, singlef4圆角

位置值

说明
"top"顶部
"center"居中
"bottom"底部

示例

// 简单提示
Toast()
.content("操作成功")
.duration(1500)
.position("center")

// 带遮罩的提示
Toast()
.type("loading")
.content("加载中...")
.duration(0)
.mask(true)
.position("center")

用于显示模态对话框。

基本用法

Modal() {
// 模态框内容
}

属性列表

属性接受类型默认值说明
visibleboolfalse是否显示
titlestring""标题
widthstring, int, singlef520宽度
heightstring, int, singlef"auto"高度
maskbooltrue是否显示遮罩
maskClosablebooltrue点击遮罩是否关闭
closablebooltrue是否显示关闭按钮
okTextstring"确定"确定按钮文字
cancelTextstring"取消"取消按钮文字
onOkfuncnull确定事件
onCancelfuncnull取消事件
onClosefuncnull关闭事件
paddingstring, int, singlef24内边距
marginstring, int, singlef0外边距
backgroundColorstring"#ffffff"背景颜色
borderRadiusstring, int, singlef6圆角
boxShadowstring"0 4px 12px rgba(0,0,0,0.15)"阴影

示例

// 确认对话框
Modal()
.visible(true)
.title("确认删除")
.width(400)
.okText("删除")
.cancelText("取消")
.onOk(() => {
// 确认删除
})
.onCancel(() => {
// 取消删除
})

// 自定义内容
Modal()
.visible(true)
.title("用户信息")
.width(600)
.height(400)
.maskClosable(false)
.onClose(() => {
// 关闭处理
})

Drawer - 抽屉

用于从侧边滑出的面板。

基本用法

Drawer() {
// 抽屉内容
}

属性列表

属性接受类型默认值说明
visibleboolfalse是否显示
titlestring""标题
placementstring"right"位置
widthstring, int, singlef300宽度
heightstring, int, singlef"100%"高度
maskbooltrue是否显示遮罩
maskClosablebooltrue点击遮罩是否关闭
closablebooltrue是否显示关闭按钮
onClosefuncnull关闭事件
paddingstring, int, singlef24内边距
marginstring, int, singlef0外边距
backgroundColorstring"#ffffff"背景颜色
borderRadiusstring, int, singlef0圆角
boxShadowstring"0 4px 12px rgba(0,0,0,0.15)"阴影

位置值

说明
"top"顶部
"right"右侧
"bottom"底部
"left"左侧

示例

// 右侧抽屉
Drawer()
.visible(true)
.title("设置")
.placement("right")
.width(400)
.onClose(() => {
// 关闭处理
})

// 底部抽屉
Drawer()
.visible(true)
.title("选择选项")
.placement("bottom")
.height(300)
.maskClosable(false)

Popover - 气泡卡片

用于显示气泡样式的弹出内容。

基本用法

Popover() {
// 气泡内容
}

属性列表

属性接受类型默认值说明
visibleboolfalse是否显示
titlestring""标题
contentstring""内容
placementstring"top"位置
triggerstring"hover"触发方式
arrowbooltrue是否显示箭头
widthstring, int, singlef"auto"宽度
heightstring, int, singlef"auto"高度
paddingstring, int, singlef12内边距
marginstring, int, singlef0外边距
backgroundColorstring"#ffffff"背景颜色
colorstring"#333333"文字颜色
borderRadiusstring, int, singlef6圆角
boxShadowstring"0 2px 8px rgba(0,0,0,0.15)"阴影

触发方式

说明
"hover"悬停
"click"点击
"focus"聚焦

示例

// 悬停提示
Popover()
.title("提示")
.content("这是一个气泡提示")
.placement("top")
.trigger("hover")

// 点击弹出
Popover()
.title("操作")
.content("确认要执行此操作吗?")
.placement("bottom")
.trigger("click")
.arrow(true)

Tooltip - 文字提示

用于显示简短的文字提示。

基本用法

Tooltip() {
// 提示内容
}

属性列表

属性接受类型默认值说明
titlestring""提示文字
placementstring"top"位置
triggerstring"hover"触发方式
arrowbooltrue是否显示箭头
delayint0延迟显示(毫秒)
widthstring, int, singlef"auto"宽度
heightstring, int, singlef"auto"高度
paddingstring, int, singlef8内边距
marginstring, int, singlef0外边距
backgroundColorstring"rgba(0,0,0,0.75)"背景颜色
colorstring"#ffffff"文字颜色
borderRadiusstring, int, singlef4圆角

示例

// 简单提示
Tooltip()
.title("这是一个按钮")
.placement("top")

// 延迟提示
Tooltip()
.title("长按查看详情")
.placement("right")
.delay(500)

Loading - 加载中

用于显示加载状态。

基本用法

Loading() {
// 加载内容
}

属性列表

属性接受类型默认值说明
loadingbooltrue是否加载中
textstring"加载中..."加载文字
sizestring"default"尺寸
spinningbooltrue是否旋转
delayint0延迟显示(毫秒)
widthstring, int, singlef"auto"宽度
heightstring, int, singlef"auto"高度
paddingstring, int, singlef16内边距
marginstring, int, singlef0外边距
backgroundColorstring"rgba(255,255,255,0.8)"背景颜色
colorstring"#1890ff"加载颜色

尺寸值

说明
"small"
"default"默认
"large"

示例

// 简单加载
Loading()
.loading(true)
.text("加载中...")

// 大尺寸加载
Loading()
.loading(true)
.text("正在处理数据")
.size("large")
.delay(300)

Spin - 加载指示器

用于显示旋转的加载指示器。

基本用法

Spin() {
// 内容
}

属性列表

属性接受类型默认值说明
spinningbooltrue是否旋转
sizestring"default"尺寸
tipstring""提示文字
delayint0延迟显示(毫秒)
widthstring, int, singlef"auto"宽度
heightstring, int, singlef"auto"高度
paddingstring, int, singlef16内边距
marginstring, int, singlef0外边距
colorstring"#1890ff"指示器颜色

示例

// 简单旋转器
Spin()
.spinning(true)

// 带提示的旋转器
Spin()
.spinning(true)
.tip("正在加载数据")
.size("large")

Skeleton - 骨架屏

用于在内容加载时显示骨架屏效果。

基本用法

Skeleton() {
// 骨架内容
}

属性列表

属性接受类型默认值说明
loadingbooltrue是否显示骨架屏
activeboolfalse是否显示动画
avatarboolfalse是否显示头像占位
titlebooltrue是否显示标题占位
paragraphbooltrue是否显示段落占位
rowsint3段落行数
widthstring, int, singlef"auto"宽度
heightstring, int, singlef"auto"高度
paddingstring, int, singlef16内边距
marginstring, int, singlef0外边距
backgroundColorstring"#f2f2f2"背景颜色
animationColorstring"#e6e6e6"动画颜色

示例

// 简单骨架屏
Skeleton()
.loading(true)
.rows(3)

// 带头像的骨架屏
Skeleton()
.loading(true)
.avatar(true)
.title(true)
.paragraph(true)
.rows(2)
.active(true)

Empty - 空状态

用于显示空状态页面。

基本用法

Empty() {
// 空状态内容
}

属性列表

属性接受类型默认值说明
imagestring""图片地址
titlestring"暂无数据"标题
descriptionstring""描述
widthstring, int, singlef"auto"宽度
heightstring, int, singlef"auto"高度
paddingstring, int, singlef24内边距
marginstring, int, singlef0外边距
backgroundColorstring"transparent"背景颜色
colorstring"#999999"文字颜色

示例

// 简单空状态
Empty()
.title("暂无数据")
.description("请稍后再试")

// 自定义图片的空状态
Empty()
.image("/images/empty.png")
.title("没有找到相关内容")
.description("请尝试其他搜索条件")

Result - 结果页

用于显示操作结果页面。

基本用法

Result() {
// 结果内容
}

属性列表

属性接受类型默认值说明
statusstring"info"结果状态
titlestring""标题
subTitlestring""副标题
extrastring""操作区内容
widthstring, int, singlef"auto"宽度
heightstring, int, singlef"auto"高度
paddingstring, int, singlef24内边距
marginstring, int, singlef0外边距
backgroundColorstring"transparent"背景颜色
colorstring"#333333"文字颜色

状态值

说明
"success"成功
"error"错误
"info"信息
"warning"警告
"404"404
"403"403
"500"500

示例

// 成功结果
Result()
.status("success")
.title("操作成功")
.subTitle("您的操作已成功完成")
.extra("返回首页")

// 错误结果
Result()
.status("error")
.title("操作失败")
.subTitle("请检查网络连接后重试")
.extra("重新尝试")

Snackbar - 消息条

用于显示简短的消息提示。

基本用法

Snackbar() {
// 消息条内容
}

属性列表

属性接受类型默认值说明
visibleboolfalse是否显示
messagestring""消息内容
actionstring""操作按钮文字
durationint4000显示时长(毫秒)
positionstring"bottom"显示位置
onActionfuncnull操作事件
onClosefuncnull关闭事件
widthstring, int, singlef"auto"宽度
heightstring, int, singlef"auto"高度
paddingstring, int, singlef16内边距
marginstring, int, singlef0外边距
backgroundColorstring"#323232"背景颜色
colorstring"#ffffff"文字颜色
borderRadiusstring, int, singlef4圆角

示例

// 基本消息条
Snackbar()
.visible(true)
.message("操作成功")
.duration(3000)
.position("bottom")

// 带操作的消息条
Snackbar()
.visible(true)
.message("文件已删除")
.action("撤销")
.onAction(() => {
// 撤销操作
})

Dialog - 对话框

用于显示对话框内容。

基本用法

Dialog() {
// 对话框内容
}

属性列表

属性接受类型默认值说明
visibleboolfalse是否显示
titlestring""标题
widthstring, int, singlef520宽度
heightstring, int, singlef"auto"高度
maskbooltrue是否显示遮罩
maskClosablebooltrue点击遮罩是否关闭
closablebooltrue是否显示关闭按钮
okTextstring"确定"确定按钮文字
cancelTextstring"取消"取消按钮文字
onOkfuncnull确定事件
onCancelfuncnull取消事件
onClosefuncnull关闭事件
paddingstring, int, singlef24内边距
marginstring, int, singlef0外边距
backgroundColorstring"#ffffff"背景颜色
borderRadiusstring, int, singlef6圆角
boxShadowstring"0 4px 12px rgba(0,0,0,0.15)"阴影

示例

// 确认对话框
Dialog()
.visible(true)
.title("确认删除")
.width(400)
.okText("删除")
.cancelText("取消")
.onOk(() => {
// 确认删除
})

// 信息对话框
Dialog()
.visible(true)
.title("提示")
.width(500)
.height(300)
.maskClosable(false)
.onClose(() => {
// 关闭处理
})

Error - 错误状态

用于显示错误状态页面。

基本用法

Error() {
// 错误状态内容
}

属性列表

属性接受类型默认值说明
titlestring"出错了"错误标题
descriptionstring"抱歉,出现了错误"错误描述
imagestring""错误图片
retryTextstring"重试"重试按钮文字
onRetryfuncnull重试事件
widthstring, int, singlef"auto"宽度
heightstring, int, singlef"auto"高度
paddingstring, int, singlef24内边距
marginstring, int, singlef0外边距
backgroundColorstring"transparent"背景颜色
colorstring"#ff4d4f"文字颜色

示例

// 基本错误状态
Error()
.title("网络错误")
.description("请检查网络连接后重试")
.retryText("重新加载")
.onRetry(() => {
// 重试操作
})

// 自定义错误状态
Error()
.title("页面加载失败")
.description("无法加载页面内容,请稍后再试")
.image("/images/error.png")
.onRetry(() => {
// 重新加载页面
})

Success - 成功状态

用于显示成功状态页面。

基本用法

Success() {
// 成功状态内容
}

属性列表

属性接受类型默认值说明
titlestring"操作成功"成功标题
descriptionstring"您的操作已成功完成"成功描述
imagestring""成功图片
actionTextstring"继续"操作按钮文字
onActionfuncnull操作事件
widthstring, int, singlef"auto"宽度
heightstring, int, singlef"auto"高度
paddingstring, int, singlef24内边距
marginstring, int, singlef0外边距
backgroundColorstring"transparent"背景颜色
colorstring"#52c41a"文字颜色

示例

// 基本成功状态
Success()
.title("保存成功")
.description("您的数据已成功保存")
.actionText("继续编辑")
.onAction(() => {
// 继续操作
})

// 自定义成功状态
Success()
.title("注册成功")
.description("欢迎加入我们!")
.image("/images/success.png")
.actionText("开始使用")
.onAction(() => {
// 跳转到首页
})