1
1
import Vue , { ComponentOptions , AsyncComponent } from 'vue'
2
2
3
3
import VueRouter from '../index'
4
- import { Route , RouteRecord , RedirectOption } from '../index'
4
+ import {
5
+ Route ,
6
+ RouteRecord ,
7
+ RedirectOption ,
8
+ NavigationFailure ,
9
+ NavigationFailureType
10
+ } from '../index'
5
11
6
12
Vue . use ( VueRouter )
7
13
@@ -11,6 +17,14 @@ const Bar = { template: '<div>bar</div>' }
11
17
const Abc = { template : '<div>abc</div>' }
12
18
const Async = ( ) => Promise . resolve ( { template : '<div>async</div>' } )
13
19
20
+ let err : any
21
+ if ( VueRouter . isNavigationFailure ( err , NavigationFailureType . aborted ) ) {
22
+ err . from . fullPath . split ( '/' )
23
+ }
24
+
25
+ let navigationFailure = new Error ( ) as NavigationFailure
26
+ navigationFailure . to . fullPath . split ( '/' )
27
+
14
28
const Hook : ComponentOptions < Vue > = {
15
29
template : '<div>hook</div>' ,
16
30
@@ -181,8 +195,16 @@ router.push({
181
195
} )
182
196
router . replace ( { name : 'home' } )
183
197
184
- router . push ( '/' , ( ) => { } , ( ) => { } )
185
- router . replace ( '/foo' , ( ) => { } , ( ) => { } )
198
+ router . push (
199
+ '/' ,
200
+ ( ) => { } ,
201
+ ( ) => { }
202
+ )
203
+ router . replace (
204
+ '/foo' ,
205
+ ( ) => { } ,
206
+ ( ) => { }
207
+ )
186
208
187
209
// promises
188
210
@@ -204,7 +226,8 @@ router.forward()
204
226
const Components : (
205
227
| ComponentOptions < Vue >
206
228
| typeof Vue
207
- | AsyncComponent ) [ ] = router . getMatchedComponents ( )
229
+ | AsyncComponent
230
+ ) [ ] = router . getMatchedComponents ( )
208
231
209
232
const vm = new Vue ( {
210
233
router,
0 commit comments