Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component's name should be automatically generated by route.name for keep-alive #95

Closed
zhiyuanzmj opened this issue Nov 16, 2022 · 3 comments

Comments

@zhiyuanzmj
Copy link
Contributor

zhiyuanzmj commented Nov 16, 2022

Description

It was inspired by vuejs/core#4993

I want to create a new plugin to implement it for this I need to export the 'getRouteMap' api.
Or implement it directly in the current plugin. like this: hannoeru/vite-plugin-pages#323 .
What do you think?

@posva
Copy link
Owner

posva commented Nov 16, 2022

Names are already generated. You can also override them in multiple ways shown in the readme
I don’t understand

@zhiyuanzmj
Copy link
Contributor Author

zhiyuanzmj commented Nov 16, 2022

In my application, I must manual specify component's name use unplugin-vue-macros for keep-alive :

<script setup>
defineOptions({
  name: '/blogs'
})
</script>

but, when I update the file structure, I also need to multiple update component's name.
so I want create a plugin to automatically generate component's name.

@posva
Copy link
Owner

posva commented Nov 16, 2022

aah, usually vue already generates the name of the component based on the filename, if you want to do something different, I believe this should be declared locally, in each component.

If you want, you can create your own vite plugin to automatically generate this part for you but keep in mind this problem is simple for common cases but gets more complicated with others (already declared export default (), etc) and the complexity added in the end is probably not worth it given how easy it is to add a name to a component

@posva posva closed this as not planned Won't fix, can't repro, duplicate, stale Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants