Pull to Refresh

将向下拖动转换为有意触发的异步刷新,并显示进度。

适用场景

  • 当界面需要以下行为时使用 Pull to Refresh:将向下拖动转换为有意触发的异步刷新,并显示进度。

安装

选择安装方式,用法示例将同步更新导入路径。

$ bunx --bun shadcn-vue@2.8.2 add https://orvui.efu.me/r/pull-to-refresh.json

此示例还需要:

终端

首次使用时,将安装的 src/components/orvui/styles.css 导入项目样式入口。

示例

预览

Pull to refresh

Activity

Pull down to check for updates

live

Motion review approved

4m

The pull request is ready to merge.

New component feedback

18m

The spring feels much closer to native now.

Registry checks passed

31m

All component files resolved successfully.

Preview deployed

1h

The latest build is ready to inspect.

Docs comment resolved

2h

The usage example now covers async refreshes.

状态与事件

此示例组合没有声明成对的受控属性与 update 事件。使用已列出的属性、原生事件和插槽组合内容;不要为它添加未公开的 v-model。

API 参考

onRefresh?
() => void | Promise<void>
—
refreshing?
boolean
false
disabled?
boolean
false
threshold?
number
76
maxPull?
number
132
holdDistance?
number
68
pullingLabel?
boolean | null | string | number | void | VNode<RendererNode, RendererElement, { [key: string]: any; }> | VNodeArrayChildren | ComponentOptions<any, any, any, ComputedOptions, MethodOptions, any, any, any, string, {}, {}, string, {}, {}, {}, string, ComponentProvideOptions> | FunctionalComponent<any, {}, any, {}> | ComponentPublicInstanceConstructor<any, any, any, any, ComputedOptions, MethodOptions>
"Pull to refresh"
releaseLabel?
boolean | null | string | number | void | VNode<RendererNode, RendererElement, { [key: string]: any; }> | VNodeArrayChildren | ComponentOptions<any, any, any, ComputedOptions, MethodOptions, any, any, any, string, {}, {}, string, {}, {}, {}, string, ComponentProvideOptions> | FunctionalComponent<any, {}, any, {}> | ComponentPublicInstanceConstructor<any, any, any, any, ComputedOptions, MethodOptions>
"Release to refresh"
refreshingLabel?
boolean | null | string | number | void | VNode<RendererNode, RendererElement, { [key: string]: any; }> | VNodeArrayChildren | ComponentOptions<any, any, any, ComputedOptions, MethodOptions, any, any, any, string, {}, {}, string, {}, {}, {}, string, ComponentProvideOptions> | FunctionalComponent<any, {}, any, {}> | ComponentPublicInstanceConstructor<any, any, any, any, ComputedOptions, MethodOptions>
"Refreshing"
ariaLabel?
string
"Refreshable content"
contentClassName?
string
—
indicatorClassName?
string
—

事件

error
[error: unknown]
@error

插槽

default
—

作用域参数: status, progress

#default

无障碍

为交互控件提供明确的无障碍名称。保留文档中的键盘路径、可见焦点与减少动态效果状态;自定义插槽应继续保留所替代部件的语义。

常见问题

如何配置 Pull to Refresh?
通过 onRefresh、refreshing、disabled、threshold、maxPull、holdDistance、pullingLabel、releaseLabel、refreshingLabel、ariaLabel、contentClassName、indicatorClassName 配置 Pull to Refresh;API 表列出其类型与默认值。
如何连接到应用状态?
监听 error,将组件连接到应用状态。
可以在服务端渲染吗?
可以在 Vue SSR 应用中正常渲染。服务端与客户端的初始 props 应保持一致;浏览器测量与交互资源在挂载后启动。

更新于