refresh 刷新

解释:可用于页面任意区域;使用时需自行添加下拉逻辑改变 offset-y 参数;smt-feed 组件对 smt-refresh 进行了封装,支持手势交互和 API 调起刷新。

属性说明

属性名类型必填默认值说明

theme

String

-

主题配置,默认浅色;深色主题请指定 dark

loadingHgt

Number

192px(需转换为设备尺寸)

加载区域高度

offsetY

Number

0

垂直移动距离,建议后续在 sjs 中使用

status

Number

0

加载状态,0:未开始,1:加载中,2:展示话术

text

String

建议最多显示 18 个汉字,超出内容截断

加载成功时的展示话术

示例

跳转编辑工具

在开发者工具中打开

在 WEB IDE 中打开

扫码体验

代码示例

百度智能小程序

请使用百度APP扫码

代码示例

  • SWAN
  • JS
  • CSS
  • JSON
  1. <view class="container {{theme}}" >
  2. <view class="refresh-wrap {{theme}}">
  3. <view class="mode-title {{theme}}">
  4. <view class="mode-title-line-left"></view>
  5. <view class="mode-title-text">手动下拉刷新</view>
  6. <view class="mode-title-line-right"></view>
  7. </view>
  8. <view
  9. class="smt-card-area"
  10. catch:touchstart="noop"
  11. catch:touchmove="noop"
  12. catch:touchend="noop"
  13. >
  14. <smt-feed
  15. class="smt-feed pull-down-refresh"
  16. ext-cls-feed="custom-cls-feed"
  17. ext-cls-loading="custom-cls-loading"
  18. theme="{{theme}}"
  19. pull-to-refresh
  20. bind:refresh="onRefresh"
  21. text="{{pullText}}"
  22. >
  23. <view class="list {{theme}}">
  24. <view
  25. class="{{'list-item ' + (val === 1 ? 'first' : '')}}"
  26. s-for="val in list"
  27. style="{{theme === 'dark' ? 'border-bottom: solid 1px rgba(255, 255, 255, .2);' : 'border-bottom: solid 1px #e0e0e0;'}}"
  28. key="{{val}}"
  29. >
  30. <view class="left">
  31. <view class="row begin"></view>
  32. <view class="row center"></view>
  33. <view class="row end"></view>
  34. </view>
  35. <view class="right"></view>
  36. </view>
  37. </view>
  38. </smt-feed>
  39. </view>
  40. </view>
  41. <view class="refresh-wrap">
  42. <view class="mode-title {{theme}}">
  43. <view class="mode-title-line-left"></view>
  44. <view class="mode-title-text">自动刷新</view>
  45. <view class="mode-title-line-right"></view>
  46. </view>
  47. <view class="smt-card-area" >
  48. <smt-feed
  49. class="smt-feed auto-refresh"
  50. ext-cls-feed="custom-cls-feed"
  51. theme="{{theme}}"
  52. disable-touch
  53. text="{{autoRefreshText}}"
  54. >
  55. <view class="list {{theme}}">
  56. <view
  57. class="{{'list-item ' + (val === 1 ? 'first' : '')}}"
  58. s-for="val in list"
  59. style="{{theme === 'dark' ? 'border-bottom: solid 1px rgba(255, 255, 255, .2);' : 'border-bottom: solid 1px #e0e0e0;'}}"
  60. key="{{val}}"
  61. >
  62. <view class="left">
  63. <view class="row begin"></view>
  64. <view class="row center"></view>
  65. <view class="row end"></view>
  66. </view>
  67. <view class="right"></view>
  68. </view>
  69. </view>
  70. </smt-feed>
  71. </view>
  72. </view>
  73. <view class="refresh-wrap">
  74. <view class="mode-title {{theme}}">
  75. <view class="mode-title-line-left"></view>
  76. <view class="mode-title-text">刷新失败</view>
  77. <view class="mode-title-line-right"></view>
  78. </view>
  79. <view class="smt-card-area fail" >
  80. <view class="fail {{fail ? 'enable' : ''}}"><view class="text">刷新失败</view></view>
  81. <smt-feed
  82. class="smt-feed auto-refresh-fail"
  83. ext-cls-feed="custom-cls-feed"
  84. theme="{{theme}}"
  85. disable-touch
  86. >
  87. <view class="list {{theme}}">
  88. <view
  89. class="{{'list-item ' + (val === 1 ? 'first' : '')}}"
  90. s-for="val in list"
  91. style="{{theme === 'dark' ? 'border-bottom: solid 1px rgba(255, 255, 255, .2);' : 'border-bottom: solid 1px #e0e0e0;'}}"
  92. key="{{val}}"
  93. >
  94. <view class="left">
  95. <view class="row begin"></view>
  96. <view class="row center"></view>
  97. <view class="row end"></view>
  98. </view>
  99. <view class="right"></view>
  100. </view>
  101. </view>
  102. </smt-feed>
  103. </view>
  104. </view>
  105. <view class="theme-control {{theme}}" >
  106. <text>沉浸式主题</text>
  107. <switch class="switch" color="{{dark ? '#f5f5f5' : '#ddd'}}" bind:change="themeChange"></switch>
  108. </view>
  109. </view>

设计指南

在刷新方式上,建议必配手动刷新,避免出现用户无法主动操作的情况。
自定义反馈文案(text)时,文案内容应合理友好,且不超过 18 个中文字符。以下为建议文案可供参考:
refresh 刷新 - 图2