Won't the change of query parameter in vue router cause the page to refresh? The view will be updated only if the page is forced to refresh. Why?

by the way, I would like to ask a question that compares low. If there is user information in the project"s header navigation, how can its data be cached when switching navigation? I will get the data again every time.

May.14,2021

query changes will not refresh the page, but you can determine whether the route has changed by monitoring. You can also use the component to guard beforeRouteUpdate. Specific usage: see the document, Baidu or Google;
cache data can be cached with a vuex, browser


    .
  1. won't (because vue's query is also placed after hash, hash changes don't cause browsers to refresh).
  2. you can integrate vuex, with a global state to store user information. When you log in, you can take it and write it to state,. Other places can use it directly
  3. .

the idea is: record the selected tab when you click navigation and append it to url, listen for the change of $route and set the navigation click status according to the tab parameter loadData of url when loadData, fallback.

export default {

    data () {
        return {
            tab: 0
        }
    },
    
    created () {
        this.onRoute()
    },
    
    watch: {
        '$route': 'onRoute'
    },
    
    onRoute () {
        this.loadData()
    },
    
    pushRouter () {
        // 
        var query = this.$route.query
        var queryString = ''
        for (let key in query) {
            if (key !== 'tab') queryString += `&${key}=${query[key]}`
        }
        this.$router.replace(`/ url?${queryString}&tab=${this.tab}`)
    },
    
    /**
    * 
    */
    loadData () {
        this.$request({
            url: ' url',
            params: {
                tab: this.tab
            }
        }).then((data) => {
            console.log(data)
        })
    },
    
    /**
    * 
    */
    clickNavigation (tab) {
        this.tab = tab
        this.pushRouter()
    }
}
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-1b34a90-2bf17.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-1b34a90-2bf17.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?