File tree Expand file tree Collapse file tree 3 files changed +47
-34
lines changed Expand file tree Collapse file tree 3 files changed +47
-34
lines changed Original file line number Diff line number Diff line change
1
+ <style >
2
+ .view {
3
+ transition : all .5s ease ;
4
+ }
5
+ .test-enter , .test-leave {
6
+ opacity : 0 ;
7
+ transform : translate3d (10px , 0 , 0 );
8
+ }
9
+ .v-link-active {
10
+ color : red ;
11
+ }
12
+ [v-cloak ] {
13
+ display : none ;
14
+ }
15
+ </style >
16
+
17
+ <template >
18
+ <div >
19
+ <p v-show =" authenticating" style =" color :red " >Authenticating...</p >
20
+ <h1 >App Header</h1 >
21
+ <a v-link =" /inbox/message/123" >inbox</a >
22
+ <a v-link =" /about" >about</a >
23
+ <a v-link =" /user/1234/profile/what" >user</a >
24
+ <a v-link =" /forbidden" >forbidden</a >
25
+ <router-view class =" view" v-transition =" test" transition-mode =" out-in" ></router-view >
26
+ </div >
27
+ </template >
28
+
29
+ <script >
30
+ module .exports = {
31
+ data : function () {
32
+ return {
33
+ authenticating: false
34
+ }
35
+ }
36
+ }
37
+ </script >
Original file line number Diff line number Diff line change 4
4
< meta charset ="utf-8 ">
5
5
< title > </ title >
6
6
< style >
7
- .view {
8
- transition : all .5s ease;
9
- }
10
- .test-enter , .test-leave {
11
- opacity : 0 ;
12
- transform : translate3d (10px , 0 , 0 );
13
- }
14
- .v-link-active {
15
- color : red;
16
- }
17
- [v-cloak ] {
18
- display : none;
19
- }
7
+
20
8
</ style >
21
9
</ head >
22
10
< body >
23
11
24
- < div id ="app " v-cloak >
25
- < p v-show ="authenticating " style ="color:red "> Authenticating...</ p >
26
- < h1 > App Header</ h1 >
27
- < a v-link ="/inbox/message/123 "> inbox</ a >
28
- < a v-link ="/about "> about</ a >
29
- < a v-link ="/user/1234/profile/what "> user</ a >
30
- < a v-link ="/forbidden "> forbidden</ a >
31
- < router-view class ="view " v-transition ="test " transition-mode ="out-in "> </ router-view >
32
- </ div >
12
+ < div id ="app "> </ div >
33
13
34
14
< script src ="http://localhost:8080/webpack-dev-server.js "> </ script >
35
15
< script src ="/example.build.js "> </ script >
Original file line number Diff line number Diff line change 1
- // NOTE: this example is based on 0.12.2 in which the
2
- // `replace` option defaults to true.
3
-
1
+ // warning: vue-router requires Vue 0.12.10+
4
2
var Vue = require ( 'vue' )
5
3
var VueRouter = require ( '../src' )
6
4
7
5
Vue . use ( VueRouter )
8
6
7
+ // create router
9
8
var router = new VueRouter ( {
10
9
history : true ,
11
10
saveScrollPosition : true
@@ -21,7 +20,10 @@ router.redirect({
21
20
} )
22
21
23
22
// global before
24
- // you can perform async rejection here
23
+ // 3 options:
24
+ // 1. return a boolean
25
+ // 2. return a Promise that resolves to a boolean
26
+ // 3. call transition.next() or transition.abort()
25
27
router . beforeEach ( function ( transition ) {
26
28
if ( transition . to . path === '/forbidden' ) {
27
29
router . app . authenticating = true
@@ -35,14 +37,8 @@ router.beforeEach(function (transition) {
35
37
}
36
38
} )
37
39
38
- var App = Vue . extend ( {
39
- data : function ( ) {
40
- return {
41
- authenticating : false
42
- }
43
- }
44
- } )
45
-
40
+ // boostrap the app
41
+ var App = Vue . extend ( require ( './app.vue' ) )
46
42
router . start ( App , '#app' )
47
43
48
44
// just for debugging
You can’t perform that action at this time.
0 commit comments