In vue, the interface depends on the change of the previous value, and the corresponding request optimization is made.

clipboard.png
watchmixinswatchloadingaxioshttploading
clipboard.png

1. Can you go to this.store.actions ("getList") as soon as you enter through the vuex, page? I tried to write
const actions = {
getGradeList ({commit}) {

.
this.$request(this.$api.home_list).then(res => {
  console.log("res111", res)
}).catch(err => {
  console.log("err", err)
})
commit()

},
}
will report an error home_list is not defined, and the this introduced by the Vue instance is also reported as an error. What should I pay attention to when I hang up and request the backend interface in actions?
2. If there is a drop-down box like this, it depends on the previous value. It is recommended that it be encapsulated into a component (whether it will be more common)

.
Nov.26,2021

does not quite understand that the landlord will have a change in the previous value of , then there are two http requests . According to personal understanding, when the page begins to load, request the interface of grade , and do not set immediate of watch to true . You can put it in the created method.


axios the list of each request is recorded in the interceptor. After the request is completed, it is emptied. When the request is the same, cancel the previous one or return the previous promise .

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