Skip to content

nested router with nested keepalive will invoke onMouted twice #12017

Open
@Dchih

Description

@Dchih

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions