Vue how to modify routing parameters if the page is not refreshed

for example, the current route is / index, when I click on the paging below, when the route becomes / index?page=1, the second page is page=2, but the page is not refreshed as a whole, only the list part is refreshed, so how to write it, ask the boss

Sep.26,2021

use vue-router 's ide/essentials/dynamic-matching.html" rel=" nofollow noreferrer "> dynamic route matching .


the data of the list is stored in data

data() {
    return {
        list: []
    }
}

use v-for to render the data in the list
when you send a request to get the data on the next page, you only need to use this.list = newList (the background data), Vue detects the data change in the data, and the list part will be re-rendered.


you can record a current page of data in data. When you click on the next page, execute the requested method, get the data and render the list again. You can take a look at the official v-for example


using historyAPI
such as history.pushState ({page:4}, "page4", "? page=4")

Menu