-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Closed
Labels
Description
Version
2.5.2
Reproduction link
http://jsfiddle.net/qkco53b9/1/
Steps to reproduce
Run the example. Look at the console.
What is expected?
Inserting a router link to a named route that doesn't exist should warn.
What is actually happening?
The console spews both warnings about the missing named routes and errors about not being able to access the regex
property of a route.
I'm building an SPA and inserting placeholder links to pages I haven't built yet.
It looks like the problem might be here:
vue-router/src/create-matcher.js
Line 39 in 4de549a
const paramNames = record.regex.keys |
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
posva commentedon Apr 30, 2017
I added that label too fast, I was sure there was already a warning 😛
Xcelled commentedon Apr 30, 2017
No, you misunderstand @posva. This is a bug, not an improvement. The warning is printed, this is fine. But there is also an error thrown:
This issue is about that error, not the warning.
posva commentedon Apr 30, 2017
The error happens because the link is pointing to a non-existent route, that's expected. The warning is there to help you out find the real problem
Xcelled commentedon Apr 30, 2017
That seems unintuitive. I would expect it to warn only (then abort), or at the very least fail gracefully with a specific error message. Instead the error message makes me think there's, well, a bug in the router.
posva commentedon Apr 30, 2017
That's right, I'll create a pr for that. Thanks!
Prevent unecessary Exception with non-existent links
Prevent unecessary Exception with non-existent links
Prevent unnecessary Exception with non-existent links (#1387)
akoidan commentedon Jun 19, 2018
Maybe we should consider altering behavior a bit?
For example, when using vue-loader, it could throw compile time error, or at least compile-time warning.
IMHO using named routes should prevent regression in big projects. Atm warnings only pop up if user visits a page with invalid route link. I'm not sure if
vue-router
has information when it receives RouterConfiguration about all vue components, so maybe it's impossible implement this w/o bundles as webpack.posva commentedon Jun 20, 2018
You could implement a webpack plugin for it but I think the current behaviour is already easy to detect because of the warnings/errors