Vue js rerender the same component when changing route

后端 未结 3 598
故里飘歌
故里飘歌 2020-12-15 23:12

I have one auth component that I am using both in the login and the signup route.

const routes = [{
  path     : \'/\',
  name: \'home\',
  component: Home
}         


        
3条回答
  •  囚心锁ツ
    2020-12-15 23:17

    You can use the key attribute to indicate vue to rerender some elements instead of reusing them.

    e.g. you have an in your Auth component which you want to rerender under different routes, add a key data prop to Auth, use in the template. In your case here,

    data() {
        key: this.$route.path
    }
    

    may be a good choice.

提交回复
热议问题