Sub Page component render only once. The create hook called once.
What is actually happening?
Sub Page component render twice, and the created hook called twice.
I have did some research about this issue, hope it helps.
Since the Home Page is keep-alived,so when jump to the About Page, the Home Page won't be unmounted, and the render effect of the Home Page's sub RouterView won't be cleared.
And then when we click this button, the currentRoute of our router changed, which will trigger all the RouterView to be re rendered. Under normal conditions, the RouterView component inside About component will be render as the Sub component. But unfortunately, the RouterView component inside Home component also be re rendered as the Sub component.
Version
3.2.19
Reproduction link
github.com
Steps to reproduce
Home
Page.About
Page.Sub
Page.What is expected?
Sub
Page component render only once. Thecreate
hook called once.What is actually happening?
Sub
Page component render twice, and thecreated
hook called twice.I have did some research about this issue, hope it helps.
Since the
Home
Page is keep-alived,so when jump to theAbout
Page, theHome
Page won't be unmounted, and the render effect of theHome
Page's subRouterView
won't be cleared.And then when we click this button, the
currentRoute
of ourrouter
changed, which will trigger all theRouterView
to be re rendered. Under normal conditions, theRouterView
component insideAbout
component will be render as theSub
component. But unfortunately, theRouterView
component inside Home component also be re rendered as theSub
component.