uniapp 下拉刷新

待我称王封你为后i 2021-07-24 17:51 634阅读 0赞
  1. 全局开启
  2. pages.json中->globalStyle
  3. "enablePullDownRefresh":true,
  4. 单页面开启
  5. pages.json->pages的数组中->对应页面内
  6. "style":{
  7. "enablePullDownRefresh":true,
  8. }
  9. 通过回调开启
  10. 在配置了页面下拉刷新后,除了可以滑动开启外
  11. 在回调函数中
  12. uni.startPullDownRefresh();
  13. 结束下拉刷新
  14. uni.stopPullDownRefresh();
  15. 监听上拉刷新生命周期函数
  16. onPullDownRefresh

下拉刷新

代码示例:

  1. <template>
  2. <view>
  3. <view class='box'>
  4. { { msg}}
  5. </view>
  6. <text class='iconfont icon-shipin '></text>
  7. <text class='iconfont'></text>
  8. <text v-if="true" v-html="hhh">wwww</text>
  9. <button type="primary" @click="get">按钮</button>
  10. <view v-for="(item,index) in list" :key="index">
  11. <view>{ { item}}</view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default{
  17. data()
  18. {
  19. return{
  20. msg:'数据',
  21. hhh:'ww',
  22. list:[1,2,3,4,5,6,7,8]
  23. }
  24. },
  25. onPullDownRefresh()
  26. {
  27. this.list.push(9);
  28. uni.stopPullDownRefresh();
  29. },
  30. methods:{
  31. get()
  32. {
  33. uni.startPullDownRefresh();
  34. }
  35. },
  36. }
  37. </script>
  38. <style scoped>
  39. @import url("../css/a.css");
  40. .box{
  41. height: 375rpx;
  42. width: 375rpx;
  43. background-color: #4CD964;
  44. }
  45. .box1{
  46. background-color: #007AFF;
  47. }
  48. </style>

pages.json:

  1. {
  2. "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
  3. {
  4. "path": "pages/message/message",
  5. "style": {
  6. "navigationBarTitleText": "study1",
  7. "backgroundColor":"#4CD964",
  8. "h5":{
  9. "pullToRefresh":{
  10. "color":"#007AFF",
  11. "offset":"20%"
  12. }
  13. },
  14. "enablePullDownRefresh":true
  15. }
  16. },
  17. {
  18. "path": "pages/index/index",
  19. "style": {
  20. "navigationBarTitleText": "uni-app"
  21. }
  22. },
  23. {
  24. "path": "pages/me/me",
  25. "style": {
  26. "navigationBarTitleText": "me"
  27. }
  28. },
  29. {
  30. "path": "pages/detail/detail",
  31. "style": {
  32. "navigationBarTitleText": "detail"
  33. }
  34. }
  35. ],
  36. "globalStyle": {
  37. "navigationBarTextStyle": "black",
  38. "navigationBarTitleText": "uni-appaa",
  39. "navigationBarBackgroundColor": "#008000",
  40. "backgroundColor": "#008000",
  41. "backgroundTextStyle":"light",
  42. "onReachBottomDistance":100
  43. },
  44. "tabBar":{
  45. "list":[
  46. {
  47. "text":"首页",
  48. "pagePath":"pages/index/index",
  49. "iconPath":"static/tabs/home.png",
  50. "selectedIconPath":"static/tabs/home-active.png"
  51. },
  52. {
  53. "text":"信息",
  54. "pagePath":"pages/message/message",
  55. "iconPath":"static/tabs/message.png",
  56. "selectedIconPath":"static/tabs/message-active.png"
  57. },
  58. {
  59. "text":"我的",
  60. "pagePath":"pages/me/me",
  61. "iconPath":"static/tabs/contact.png",
  62. "selectedIconPath":"static/tabs/contact-active.png"
  63. }
  64. ],
  65. "color":"#9CDCFE",
  66. "selectedColor":"#008000",
  67. "backgroundColor":"#272822",
  68. "borderStyle":"white"
  69. },
  70. "condition":{
  71. "current":0,
  72. "list":[
  73. {
  74. "name":"详情页",
  75. "path":"pages/detail/detail",
  76. "query":"id=80"
  77. }
  78. ]
  79. }
  80. }

发表评论

表情:
评论列表 (有 0 条评论,634人围观)

还没有评论,来说两句吧...

相关阅读

    相关 uniapp 刷新

    这里,最好仔细看一下scroll-view组件的api介绍。scroll-view | uni-app官网//开启自定义下拉刷新//初始情况下,关闭刷新状态/*自定义下拉...