SoFunction
Updated on 2025-04-05

Implement pull-up refresh function based on Vue framework vux component library

Recently, the company has been developing an app and selected a vux component library based on the Vue framework. Now we will summarize the pitfalls encountered in implementing the pull-up refresh function:
1. Problem: Only refresh once, solution: you need to manually reset the status yourself
= ‘default',
2. Problem: Cannot scroll, solution: Because keep-alive cache is enabled, you need to set it

activated () {
 this.$()
}

If it doesn't work yet, please execute the following code after obtaining the background data

this.$nxtTick(() => {
    this.$()
   })

Post the code for the entire page.

<template> 
  <div style="height:100%;">

    <x-header slot="header" :left-options="{showBack: false}" >Meeting List 
    <a slot="right" v-on:click="show = true" > <icon type="search"></icon> </button> </a> 
    </x-header>

    <!-- Meeting List -->
    <scroller v-model="scrollerStatus" height="-46"  lock-x scrollbar-y ref="scroller" :bounce="isbounce" :use-pullup="showUp" :pullup-config="upobj" @on-pullup-loading="selPullUp" >
    <div class="box2">
      <p v-for="list, index in lists">  
         <router-link :to="{ path:  } ">
           <p style="height:40px;"> 
            <span class="spanMeetTitle" v-html='(index+1) + " . " + ' ></span>
            <span class="spanMeetStatu" v-html=''></span>
           </p> 
          <p class="prevSuper">
           <form-preview header-label="" header-value="" :bodyItems="list" :footer-buttons="buttons1"></form-preview>
          </p>
          </router-link>  
          <hr>  
       </p> 
    </div>
    </scroller>

   <!-- navigation -->
   <Home></Home>

   <!-- search --> 
   <popup v-model="show" @on-hide="log('hide')" @on-show="log('show')" height="93%">
   <div class="popup0">
    <group> 
     <x-input v-model='meetName' placeholder="Please enter "Conference Name" to search"></x-input> 
     <div style="float:left;margin-top: -36px;"><icon type="search"></icon></div> 
    </group>
 <!--  
    <group> 
     <checklist :max=1 title="Meeting Approval Status" required :options="commonList" v-model="checkStatus" @on-change="change"></checklist> 
    </group> -->

     <group title="Meeting Approval Status">
     <radio :options="commonList" v-model="checkStatus" @on-change="change"></radio>
    </group>

    <group title="Conference Type">
      <selector placeholder="Please select the meeting type" v-model="checkType" :options="meetType"></selector>
    </group>

     <group title="Convene time">
     <flexbox>
      <flexbox-item>
      <div class="flex-demo" style="background-color:white;color:black;height:45px"> 
       <datetime title='' placeholder="Please select" v-model="startTime" format="YYYY-MM-DD HH:mm" @on-change="change" ></datetime>
      </div>
      </flexbox-item>
      to
      <flexbox-item>
      <div class="flex-demo" style="background-color:white;color:black;height:45px">
       <datetime title='' placeholder="Please select" v-model="stopTime" format="YYYY-MM-DD HH:mm" @on-change="change" ></datetime>
      </div>
      </flexbox-item>
     </flexbox> 
    </group>
    <br>
    <flexbox orient="vertical">
     <flexbox-item><div class="flex-demo" v-on:click="toSearch" >Sure</div></flexbox-item>
     <flexbox-item><div class="flex-demo" v-on:click="show = false" style="background-color:white;color:black">Cancel</div></flexbox-item>
    </flexbox>

   </div>
  </popup>

  <toast v-model="showToast">All data has been loaded</toast>

  <loading v-model="isShowLoading" :text="textLoading"></loading>

  <alert v-model="isShowAlert" :title="AlertCongratulations" > {{ alertMessage }}</alert>
  </div>
</template>

<style type="text/css">
 .weui-form-preview__value{
  font-size: 1.1em !important;
  color: black;
 }
 .spanMeetTitle{
  float: left; 
  border-radius: 13px;
  padding:10px 6px; 
  font-size: 15px; 
  font-weight: bold;
  margin-left: 3px;
  color: black;
 }
 .spanMeetStatu{
   float: right;
   background-color: green;
   border-radius: 10px;
   padding:6px 5px;
   color: white;
   font-size: 13px;
   margin-top: 5px;
 }
 .flex-demo{
  height: 30px;padding-top: 5px; 
 }
 .selected{
  color: blue !important;
  background-color: transparent;
 }
 .popup0 {
 padding-bottom:15px;
 height:200px;
 }
 .popup1 {
  width:100%;
  height:100%;
 }
 .popup2 {
  padding-bottom:15px;
  height:400px;
 }
 .box1 {
  height: 100px;
  position: relative;
  width: 1490px;
 }
 .box1-item {
  width: 200px;
  height: 100px;
  background-color: #ccc;
  display:inline-block;
  margin-left: 15px;
  float: left;
  text-align: center;
  line-height: 100px;
 }
 .box1-item:first-child {
  margin-left: 0;
 }
 .box2-wrap {
  height: 300px;
  overflow: hidden;
 }
</style>

<script>
import { XHeader, Group, FormPreview, Tabbar, TabbarItem, Scroller, Icon, Popup, XSwitch, Toast, XInput, Checklist, Datetime, Flexbox, FlexboxItem, Selector, Loading, Alert, Radio } from 'vux'
import Home from './Home'

export default {
 components: {
  XHeader,
  Home,
  Group,
  FormPreview,
  Tabbar,
  TabbarItem,
  Scroller,
  Icon,
  Popup,
  XSwitch,
  Toast,
  XInput,
  Checklist,
  Datetime,
  Flexbox,
  FlexboxItem,
  Selector,
  Loading,
  Alert,
  Radio
 },
 data () {
  return {
   type: '1',
   PageIndex: 0,
   show: false,
   showToast: false,
   showloading: false,
   showUp: true,
   isbounce: false,
   isShowAlert: false,
   AlertCongratulations: 'The conditions are wrong',
   textloading: 'loading',
   alertMessage: ''Convening time' Can't be greater than ‘End time'',
   value: '',
   meetName: '',
   startTime: '',
   stopTime: '',
   meetType: [],
   commonList: [{key: '20', value: 'Approval'}, {key: '50', value: 'Approval'}, {key: '', value: 'all'}],
   checkStatus: '',
   checkType: '',
   commonList2: [],
   results: [],
   lists: [[]],
   buttons1: [{
    style: 'primary',
    text: 'See more',
    link: '/Message'
   }],
   upobj: {
    content: 'Please pull up and refresh the data',
    pullUpHeight: 60,
    height: 40,
    autoRefresh: false,
    downContent: 'Please pull up and refresh the data',
    upContent: 'Please pull up and refresh the data',
    loadingContent: 'loading...',
    clsPrefix: 'xs-plugin-pullup-'
   },
   isShowLoading: false,
   textLoading: 'loading',
   scrollerStatus: {
    pullupStatus: 'default'
   }
  }
 },
 mounted () {
  ()
  (true)
  ()
  this.$nextTick(() => {
   this.$()
  })
 },
 methods: {
  log (str) {
   (str)
  },
  getMeetList (isEmpty) {
   var APPROVE_STATUS = 
   var MEETING_TYPE = 
    = true
   this.$( + '/Meet/GetMeetList', {'HumanId': , 'KEY': , 'APPROVE_STATUS': APPROVE_STATUS, 'MEETING_TYPE': MEETING_TYPE, 'START_DATE': , 'STOP_DATE': , 'PageIndex': , 'PageSize': '2'}).then(response => {
   // sucess callback
    ('111')
    var data = 
    if (isEmpty) {
      = []
      = false
    } else {
     if (data &&  === 0) {
       = true
       = false
       = 'disabled' // Disable pull-down      return
     }
    }
    for (var i = 0; i < ; i++) {
     if (data[i].APPROVE_STATUS < 20) {
      break
     }
     var personName = data[i].PERSION1_NAME
     if (personName &&  > 0) {
      personName = (0, ('>'))
     }
     var meetlist = []
     var obj = {
      label: 'Place',
      value: data[i].ADDRESS
     }
     (obj)
     obj = {
      label: 'host',
      value: personName
     }
     (obj)
     obj = {
      label: 'Convening time',
      value: (data[i].ACT_START_TIME, 'yyyy-MM-dd HH:mm')
     }
     (obj)
     obj = {
      label: 'Conference Type',
      value: data[i].MEETING_TYPE_NAME
     }
     (obj)
      = 'FromMeet/' + data[i].MEETING_MINUTES_GUID + '/123'
      = data[i].MEETING_NAME
     var vstatus = 'Approval'
     if (data[i].APPROVE_STATUS === 50) {
      vstatus = 'Approval'
     }
      = vstatus
     (meetlist)
    }
     = false
    if (!isEmpty) {
      = 'default'
     // this.$()
     ()
     this.$nextTick(() => {
      this.$()
     })
    }
   }, response => {
   // error callback
     = false
   })
  },
  showSearch () {
    = true
  },
  change (val) {
   ('change', val)
   ()
  },
  change2 (val) {
   ('change', val)
  },
  resultClick () {
  },
  getResult () {
  },
  toSearch () {
   (2222)
   if ( &&  &&  > ) {
     = true
   } else {
     = 0
    (true)
   }
  },
  selPullUp () {
   ('Pull-up refresh data')
   ++
   (false)
  },
  getMeetType () {
   this.$( + '/Meet/GetMeetType').then(response => {
    // sucess callback
    var data = 
    for (var i =  - 1; i >= 0; i--) {
     var obj = {
      key: data[i].TYPE_GUID,
      value: data[i].TYPE_NAME
     }
     (obj)
    }
   }, response => {
   // error callback
   })
  }
 },
 activated () {
  this.$()
 }
}
</script>

 <style lang="less">
@import '~vux/src/styles/';

.flex-demo {
 text-align: center;
 color: #fff;
 background-color: #20b907;
 border-radius: 4px;
 background-clip: padding-box;
}
</style>

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.