Vue routing Guard axios request data

vue route guard axios request data
requirement:
before entering the page, axios requests data and, according to judgment, jumps to the corresponding route.

practice:

1beforeRouteEnter 
axiosaxios
2created
3

excuse me: is there any other way?

Mar.22,2021

practice 1 can be found in the router.js import axios instance

other methods:

  1. you can use Router.routes 's beforeEnter (exclusive routing guard)
  2. you can use beforeRouteEnter (guards within components)
  3. call the global beforeResolve guard

clipboard.png

clipboard.png

finally, introduce axios, into router.js and use prototype pointing, because using axios.get directly will report the error of protocol, so use prototype


have you solved it


beforEnter(to, form ,next){
next(vm=>{
vm.$httpAxios.get
})
}

nextvue
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-1b35cdf-2bfb8.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-1b35cdf-2bfb8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?