Vue, under a single page, the custom component passes values to router-view, which is only valid for the first jump. How to solve the problem

the problem is not easy to describe. I will add the picture and text to describe the problem in detail

this is the configuration relationship of router

clipboard.png

clipboard.png

clipboard.png

clipboard.png

clipboard.png

clipboard.png

vuexweb_searchInfovuex

clipboard.png

Note: as shown in the picture, there is a way to create a new window (in fact, it is not called resolution), but I do not like to re-search to create a new page, which makes it look too bloated (referring to too many windows). Is there any boss who knows other solutions? ask for advice

Jul.06,2022

on the search page, use beforeRouteUpdate () to search. In addition, search_key does not need to save to vuex. Click button Yes, router.push (params:key). On the search page beforerouteenter (), use to.params.key to get the keyword


watch route, and execute the data acquisition method


again.

because your search component is already active in the first search, resending routing will not cause component reloading. This is for rendering performance considerations. For the query of search results and the display of the page, you should listen for changes in this parameter to initiate requests, instead of focusing on page reloading. For example, listen to this.$route.params.key_word :

in the view shown in the results according to your parameters.
https://router.vuejs.org/zh/g...</a>

watchwatch

getSearchInfo()apiroute

 const result = await this.$apis.ArticleApi.get_search(this.$route.params.key_word,this.search_page,this.searchType);
Menu