Skip to content

Commit 14bd496

Browse files
committed
update example
1 parent 76b0cde commit 14bd496

File tree

3 files changed

+47
-34
lines changed

3 files changed

+47
-34
lines changed

example/app.vue

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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>

example/index.html

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,12 @@
44
<meta charset="utf-8">
55
<title></title>
66
<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+
208
</style>
219
</head>
2210
<body>
2311

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>
3313

3414
<script src="http://localhost:8080/webpack-dev-server.js"></script>
3515
<script src="/example.build.js"></script>

example/index.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
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+
42
var Vue = require('vue')
53
var VueRouter = require('../src')
64

75
Vue.use(VueRouter)
86

7+
// create router
98
var router = new VueRouter({
109
history: true,
1110
saveScrollPosition: true
@@ -21,7 +20,10 @@ router.redirect({
2120
})
2221

2322
// 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()
2527
router.beforeEach(function (transition) {
2628
if (transition.to.path === '/forbidden') {
2729
router.app.authenticating = true
@@ -35,14 +37,8 @@ router.beforeEach(function (transition) {
3537
}
3638
})
3739

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'))
4642
router.start(App, '#app')
4743

4844
// just for debugging

0 commit comments

Comments
 (0)