File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 1
- const internalKeysRE = / ^ ( c o m p o n e n t | s u b R o u t e s ) $ /
1
+ const internalKeysRE = / ^ ( c o m p o n e n t | s u b R o u t e s | n a m e | f u l l P a t h ) $ /
2
2
3
3
/**
4
4
* Route Context Object
Original file line number Diff line number Diff line change @@ -80,14 +80,28 @@ export default function (Vue, Router) {
80
80
81
81
/**
82
82
* Navigate to a given path.
83
+ * The path can be an object describing a named path in
84
+ * the format of { name: '...', params: {}, query: {}}
83
85
* The path is assumed to be already decoded, and will
84
86
* be resolved against root (if provided)
85
87
*
86
- * @param {String } path
88
+ * @param {String|Object } path
87
89
* @param {Boolean } [replace]
88
90
*/
89
91
90
92
Router . prototype . go = function ( path , replace ) {
93
+ // handle named routes
94
+ if ( typeof path === 'object' ) {
95
+ if ( path . name ) {
96
+ var params = path . params || { }
97
+ if ( path . query ) {
98
+ params . queryParams = path . query
99
+ }
100
+ path = this . _recognizer . generate ( path . name , params )
101
+ } else if ( path . path ) {
102
+ path = path . path
103
+ }
104
+ }
91
105
this . history . go ( path + '' , replace )
92
106
}
93
107
Original file line number Diff line number Diff line change @@ -22,7 +22,10 @@ export default function (Vue, Router) {
22
22
path : path ,
23
23
handler : handler
24
24
} )
25
- this . _recognizer . add ( segments )
25
+ this . _recognizer . add ( segments , {
26
+ as : handler . name
27
+ } )
28
+ // add sub routes
26
29
if ( handler . subRoutes ) {
27
30
for ( let subPath in handler . subRoutes ) {
28
31
// recursively walk all sub routes
You can’t perform that action at this time.
0 commit comments