- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 101
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Router parameter naming style conversion #465
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
Comments
You can indeed automatically convert them by using the extendRoute(route) {
// transform kebab-case to camelCase
route.params.forEach((param, i) => {
const newParam = param.paramName.replace(/-([a-z])/g, (g) =>
g[1].toUpperCase()
)
route.path = route.path.replace(`:${param.paramName}`, `:${newParam}`)
param.paramName = newParam
})
} But also, the generated TS should be correct, so it should be |
Thanks for your answer. Will this become a built-in feature? |
Right now I don’t think it needs a dedicated option |
|
I updated the function, it does require you to change the path too. |
Not work, but got warning: |
That's #341, so you will need a bit more code to handle it right now |
I'm still not convinced at all for the need of an option to handle this. Naming the files so they match vue router params seems like a good practice |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Currently, if I have
pages/user/[u-id]/group/[g-id].vue
, it will generate params like:And
u-id
andg-id
are not valid JavaScript attribute names.Is it possible to add some kind of automatic conversion? It should also be configurable to convert to multiple naming styles, like camelCase, underscores or raw style.
The text was updated successfully, but these errors were encountered: