Vue has just entered the interface of the component to load so the page, and then refreshed the interface every 5 minutes, how to achieve it?

because the mobile project we are doing now will eventually be enclosed in the app shell. I put the axios request of each component in the created. Go to the component to send the request and get the data

.

clipboard.png

clipboard.png

the requirement now is that all components send requests to get data directly when you first log in, instead of sending requests to get data when you enter the component.
is there any good way to do this? Or do not enter the method inside the component trigger component?

Mar.17,2021

if you do not enter the component, you can put the request in the beforeRouteEnter hook, or you can use the first one in init, after the request is completed in mainJS, because it will be a bit messy for all your requests to be placed in mainJS.

import axios from 'axios'

beforeRouteEnter(to, from, next) {
  axios.get().then(function (res) {
    // res
    next(vm => {
      vm.username = res.data.data.username
      vm.age = res.data.data.age
    })
  })
},
data () {
  return {
    username: '',
    age: ''
  }
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31480-e2cf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31480-e2cf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?