Skip to content

Use route name as page component's name as default #33254

@jdgjxxchy

Description

@jdgjxxchy

Describe the feature

There is an error happened when I use keepalive: { include: ['xxx'] } in NuxtPage
When I was arrange my page structure like this:

  • pages
    -- foo
    --- index.vue
    -- bar
    --- index.vue
    It render two pages with name foo and bar
    I need to dynamicly add keepalive page, such as ['foo'], ['bar'], ['foo', 'bar'], when I was passing it to keepalive: {include:[]}, it didn't work at all.

The question is that the name of the component is neither foo or bar, is index instead, so keepalive component cannot keep the child component alive.

Image

What I can do is to add

 defineOptions({
   name: 'foo',
 }) 

to each component to change its name so that keepalive can work properly.

Is there any way to automaticly use route name as its component name?

Additional information

  • Would you be willing to help implement this feature?
  • Could this feature be implemented as a module?

Final checks

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions