File tree 2 files changed +45
-0
lines changed
2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ import Vue from 'vue/dist/vue'
2
+ import VueRouter from 'vue-router'
3
+
4
+ Vue . use ( VueRouter )
5
+
6
+ const Home = { template : '<div><h1>Home</h1><router-view></router-view></div>' }
7
+ const Foo = { template : '<div>foo</div>' }
8
+ const Bar = { template : '<div>bar</div>' }
9
+ const Baz = { template : '<div>baz</div>' }
10
+
11
+ const router = new VueRouter ( {
12
+ mode : 'history' ,
13
+ base : __dirname ,
14
+ routes : [
15
+ { path : '/home' , component : Home , children : [
16
+ // absolute alias
17
+ { path : 'foo' , component : Foo , alias : '/foo' } ,
18
+ // relative alias (alias to /home/bar-alias)
19
+ { path : 'bar' , component : Bar , alias : 'bar-alias' } ,
20
+ // multiple aliases
21
+ { path : 'baz' , component : Baz , alias : [ '/baz' , 'baz-alias' ] }
22
+ ] }
23
+ ]
24
+ } )
25
+
26
+ const app = new Vue ( {
27
+ router,
28
+ template : `
29
+ <div id="app">
30
+ <h1>Route Alias</h1>
31
+ <ul>
32
+ <li><router-link to="/foo">/foo (renders /home/foo)</router-link></li>
33
+ <li><router-link to="/home/bar-alias">/home/bar-alias (renders /home/bar)</router-link></li>
34
+ <li><router-link to="/baz">/baz (renders /home/baz)</router-link></li>
35
+ <li><router-link to="/home/baz-alias">/home/baz-alias (renders /home/baz)</router-link></li>
36
+ </ul>
37
+ <router-view class="view"></router-view>
38
+ </div>
39
+ `
40
+ } ) . $mount ( '#app' )
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < a href ="/ "> Examples index</ a >
3
+ < div id ="app "> </ div >
4
+ < script src ="/__build__/shared.js "> </ script >
5
+ < script src ="/__build__/route-alias.js "> </ script >
You can’t perform that action at this time.
0 commit comments