File tree Expand file tree Collapse file tree 4 files changed +124
-0
lines changed
Expand file tree Collapse file tree 4 files changed +124
-0
lines changed Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ /**
4+ * ['/history/page']
5+ * The path used by history mode
6+ */
7+ exports . page = function * ( ) {
8+ yield this . bindDefault ( )
9+
10+ yield this . render ( 'history' , {
11+ siteInfo : this . siteInfo
12+ } )
13+ }
14+ /**
15+ * Match all path (begins with '/history/page/').
16+ * Such as: /history/page/:any-words/:any-times/...
17+ */
18+ exports . page . __regular__ = / ^ \/ h i s t o r y \/ p a g e \/ (?: .* ) (?: \/ (? = $ ) ) ? $ /
19+
20+ /**
21+ * ['/history' & '/history/page']
22+ * Make the index path redirect to history path automatically
23+ */
24+ exports . index = exports . page
25+
26+ /**
27+ * ['/history/ajax']
28+ * Other paths to do other things
29+ */
30+ exports . ajax = {
31+ demo : function * ( ) {
32+ yield this . proxy ( `http://${ this . host } /ajax/test/1` )
33+ }
34+ }
Original file line number Diff line number Diff line change 1+ // The Vue build version to load with the `import` command
2+ // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
3+ import Vue from 'vue'
4+ import VueRouter from 'vue-router'
5+ import VueResource from 'vue-resource'
6+ import routes from './router.js'
7+ import App from './index.vue'
8+
9+ // 初始化路由
10+ /* eslint-disable no-new */
11+ const router = new VueRouter ( routes )
12+
13+ // 置入组件
14+ Vue . use ( VueRouter )
15+ Vue . use ( VueResource )
16+
17+ new Vue ( {
18+ /**
19+ * 提供的元素只能作为挂载点。
20+ * 不同于 Vue 1.x,所有的挂载元素会被 Vue 生成的 DOM 替换。
21+ * 因此不推荐挂载root实例到 <html> 或者 <body> 上。
22+ */
23+ el : '#app' ,
24+ template : '<App/>' ,
25+ components : { App } ,
26+ /**
27+ * 置入路由
28+ */
29+ router
30+ } )
31+ /* eslint-enable no-new */
Original file line number Diff line number Diff line change 1+ <template >
2+ <div id =" history" >
3+ <router-view ></router-view >
4+ </div >
5+ </template >
6+
7+ <script >
8+ export default {
9+ name: ' history'
10+ }
11+ </script >
12+
13+ <style lang="less">
14+ #history {
15+ /* some style */
16+ }
17+ </style >
Original file line number Diff line number Diff line change 1+ const prefix = '/history/page'
2+
3+ function getDemoHtml ( path ) {
4+ return `<div>
5+ <a href="${ prefix } ${ path } ">
6+ <a> will Reload-The-Page as usual!
7+ </a>
8+ <br>
9+ <router-link to="${ prefix } ${ path } ">
10+ <router-link> use real History api!
11+ </router-link>
12+ <span style="color: red;">[use this!]</span>
13+ </div>`
14+ }
15+
16+ module . exports = {
17+ mode : 'history' ,
18+ routes : [ {
19+ path : `${ prefix } /index` ,
20+ component : {
21+ template : getDemoHtml ( '/list' )
22+ }
23+ } , {
24+ path : `${ prefix } /list` ,
25+ component : {
26+ template : getDemoHtml ( '/test' )
27+ }
28+ } , {
29+ path : `${ prefix } /test` ,
30+ component : {
31+ template : getDemoHtml ( `/test/${ Math . random ( ) . toString ( 36 ) . substring ( 2 ) } ` )
32+ }
33+ } , {
34+ path : `${ prefix } /test/:test` ,
35+ component : {
36+ template : getDemoHtml ( '/index' )
37+ }
38+ } , {
39+ path : '*' ,
40+ redirect : `${ prefix } /index`
41+ } ]
42+ }
You can’t perform that action at this time.
0 commit comments