The page component re-renders twice after changing and replacing the layout component. #8688
Unanswered
Mini-ghost
asked this question in
Help/Questions
Replies: 2 comments
-
You can directly use Nuxt to set up a project and handle |
Beta Was this translation helpful? Give feedback.
0 replies
-
You can add an initialization print to LayoutB and you'll be able to figure it all out. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Problem Reproduction:
https://stackblitz.com/edit/vue-dynamic-layout?file=src%2FApp.vue,src%2Fmain.ts&terminal=dev
I am currently using vue-router's meta to switch between different layouts for different pages. To reduce the bundle size, dynamic loading is used for the layout components.
However, when switching from page A to page B, which have different layouts, the page component gets rendered twice.
In the video below, "render page b with layout b" is printed twice when switching from page A to page B for the first time:
2023-07-01.11.20.35.mov
The code is written in
App.vue
in the video is as follows:If I make the following change to the code, the problem will be resolved:
2023-07-01.11.32.18.mov
I'm not sure why this happens, but when I separate the Layout component into a standalone component and perform the same logic inside it, there is no issue with repeated rendering. I'm very curious to know the reason behind this. Can someone share their thoughts on this?
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions