-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
feat(route-config): add support for props and alias #3818
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #3818 +/- ##
=======================================
Coverage 97.84% 97.84%
=======================================
Files 18 18
Lines 1162 1162
Branches 317 317
=======================================
Hits 1137 1137
Misses 24 24
Partials 1 1 Continue to review full report at Codecov.
|
@@ -11,6 +11,9 @@ import Router from 'vue-router' | |||
res += (route.component) ? ',\n\t' + tab + 'component: ' + (splitChunks.pages ? route._name : `() => ${route._name}.default || ${route._name}`) : '' | |||
res += (route.redirect) ? ',\n\t' + tab + 'redirect: ' + JSON.stringify(route.redirect) : '' | |||
res += (route.meta) ? ',\n\t' + tab + 'meta: ' + JSON.stringify(route.meta) : '' | |||
res += (typeof route.props !== 'undefined') ? ',\n\t' + tab + 'props: ' + (typeof route.props === 'function' ? serialize(route.props) : JSON.stringify(route.props)) : '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency, this may be simplified into (route.props)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to vue-router
docs, props
can have Boolean value, so we can't just check its falsy value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@farnabaz Regardless, route.props != null
is the canonical way of checking null
/undefined
values in javascript. According to clean-code rules, checking for positive instead of negative is considered slightly easier to read. Robert C. Martin
If doesn't appear to be anywhere where null
is accepted instead of undefined
, so the code should be:
res += route.props == null ? '' : ',\n\t' + tab + 'props: ' + (typeof route.props === 'function' ? serialize(route.props) : JSON.stringify(route.props))
Right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dotnetCarpenter You're right. I'll create a new pull request to cleanup my code.
Thank you very much for your comment :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest adding a comment link to the API source for better maintenance: https://router.vuejs.org/api/#routes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add docs to api/extendRoutes section: https://github.com/nuxt/docs/blob/2.0/en/api/configuration-router.md#extendroutes |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Currently nuxtjs support some of
vue-router
route configs and some use fill configs likealias
andprops
is missing