SoFunction
Updated on 2025-04-03

vue realizes timed refresh data, executed every 5 minutes

Vue refreshes data regularly and executes every 5 minutes

data() {
  return {
    timer: null
  }
},
mounted() {
   // Refresh regularly every 5 minutes    = setInterval(() => {
     ();
   }, 300000)
 },
 beforeDestroy() {
   clearInterval();
 },
 methods: {
 getFxItemlist() {
   ...
 }
}

vue local timed refresh

Timer refresh usually comes with timer, vue local timer refresh is as follows:

Set the timer

    timer: "",//Timer    
    //Timer refreshes to-do items      = setInterval(() => {
      ();
    }, 1000);

Partial refresh

 <div class="DealtTop" v-if="isRefreshAlive">
 
 isRefreshAlive: true, //refresh//Parent refresh    reload() {
       = false;
      this.$nextTick(function() {
         = true;
      });
    },

If it is in a parent-child component, you need to add provide/inject to use, as follows:

 provide() {
    return {
      reload: 
    };
  },

Clear the timer

destroyed(){
    clearInterval();
  },

Summarize

The above is personal experience. I hope you can give you a reference and I hope you can support me more.