core icon indicating copy to clipboard operation
core copied to clipboard

nested router with nested keepalive will invoke onMouted twice

Open Dchih opened this issue 1 year ago • 2 comments

Vue version

^3.4.29

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-otefqw

Steps to reproduce

click switch(切换) button, check console , then you'll see twice output

What is expected?

call onMounted once

What is actually happening?

nested router-view width nested keepalive will cause twice onMounted hook call in inner nested component. 目的是想让 keep-alive 缓存嵌套路由的所有组件,结果发现二层嵌套中 keep-alive 包的组件在首次切换的时候会调用两次 onMounted

System Info

win10
chrome@latest

Any additional comments?

No response

Dchih avatar Sep 24 '24 05:09 Dchih

similar to https://github.com/vuejs/core/issues/7280 duplicate of https://github.com/vuejs/core/issues/3937 For more detail see https://github.com/vuejs/router/issues/626

edison1105 avatar Sep 24 '24 07:09 edison1105