Refresh the page in vue, only refresh the main part, but not the navigation bar.

Click the refresh button only to change the main part, navigation bar and sidebar do not change how to achieve?

< template >
< div id= "app" >

in

app.VUE

<router-view v-if="isRouterAlive"></router-view>
<!-- <router-view></router-view> -->

< / div >
< / template >

< script >
export default {
name: "App",
provide () {

return {
  reload: this.reload
}

},
data () {

return {
  isRouterAlive:true
}

},
methods: {

reload() {
  this.isRouterAlive = false
  this.$nextTick(function(){
    this.isRouterAlive = true
  })
}

}
}
< / script >
export default {
inject: ["reload"],

in the component

data () {

return {

},
    
handleRefres() {
  this.reload()
    
 
},
Mar.31,2022

your refresh is just to pull down the data again


if you call reload, the whole page will be refreshed. If you just want to refresh the main section, reset the data.


you can see that the method of pulling data should be called in the hook created by the list component. Now all you want to do is destroy the list component actively and then create it, but your dom is all loaded, and it doesn't make any sense to use $nextTick.
it is recommended to change it to a timer and try again

this.isRouterAlive = false
setTimeout(() => {
    this.isRouterAlive = true
}, 200)
Menu