execute the this.$router.push () method on the "game-detail" page, and jump to the" game-detail", page without refreshing.
because the body of the route has not changed, only the passed parameter id
, so there is no jump from "game-detail?id=1" to" game-detail?id=2",.
but you can listen for $route, to listen for id changes in watch.
then I listened to the route in watch and clicked on it. The methods function that gets the page data is called again.
wants to simulate page refresh by refreshing the page data and zeroing the scroll bar.
and then. After clicking. The data has been refreshed and the page has not changed.
the parent component is passed to the child component through props. What should I do in the child component?
just now Baidu found that some people said that it was watch and deep listening in the sub-component,
and then I heard that the data had changed and then it was still not possible to assign values in the sub-component.
part of parent component:
<child :data="dataList"/>
data:dataList: []
this.$http.get().then((res)=>{
this.dataList.splice(0, this.dataList.length, ...res)
})
watch section:
watch: {
$route(to, from) {
this.$http.get().then((res)=>{
this.dataList.splice(0, this.dataList.length, ...res)
})
}
}
part of sub-components:
<div>{{ getData.name }}</div>
props: ["data"]
data:getData: this.data[0]