Skip to content

Commit 859162c

Browse files
committed
fix invalid component warning
1 parent db5125c commit 859162c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ class Router {
267267
*/
268268

269269
_addRoute (path, handler, segments) {
270-
guardComponent(handler)
270+
guardComponent(path, handler)
271271
segments.push({
272272
path: path,
273273
handler: handler
@@ -297,7 +297,7 @@ class Router {
297297
*/
298298

299299
_notFound (handler) {
300-
guardComponent(handler)
300+
guardComponent('*', handler)
301301
this._notFoundHandler = [{ handler: handler }]
302302
}
303303

@@ -523,10 +523,11 @@ class Router {
523523
* Allow directly passing components to a route
524524
* definition.
525525
*
526+
* @param {String} path
526527
* @param {Object} handler
527528
*/
528529

529-
function guardComponent (handler) {
530+
function guardComponent (path, handler) {
530531
let comp = handler.component
531532
if (Vue.util.isPlainObject(comp)) {
532533
comp = handler.component = Vue.extend(comp)
@@ -535,7 +536,7 @@ function guardComponent (handler) {
535536
if (typeof comp !== 'function') {
536537
handler.component = null
537538
warn(
538-
'invalid component for route "' + handler.path + '"'
539+
'invalid component for route "' + path + '".'
539540
)
540541
}
541542
}

0 commit comments

Comments
 (0)