└── myvue ├── .gitignore ├── src ├── assets │ ├── book.jpg │ ├── car.jpg │ ├── logo.png │ ├── map.jpg │ ├── news.jpg │ ├── user.jpg │ ├── jiantou.png │ ├── top_bg.jpg │ └── default_photo.png ├── component │ ├── footer.vue │ ├── active.vue │ ├── artical.vue │ ├── xiang.vue │ ├── round.vue │ ├── liuyan.vue │ ├── lun.vue │ ├── artdet.vue │ ├── register.vue │ ├── my.vue │ ├── login.vue │ ├── car.vue │ ├── ymain.vue │ └── rdetail.vue ├── App.vue ├── js │ ├── rem.js │ ├── axios.min.js │ ├── touch.min.js │ ├── vue-router.min.js │ ├── zepto-1.1.6.min.js │ └── vue-router.js ├── css │ └── reset.css ├── json │ ├── zaojiao2.json │ ├── zaojiao1.json │ └── zaojiao.json └── main.js ├── .babelrc ├── .idea ├── encodings.xml ├── misc.xml ├── modules.xml ├── myvue.iml └── workspace.xml ├── README.md ├── index.html ├── package.json └── webpack.config.js /myvue/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | dist/ 4 | npm-debug.log 5 | yarn-error.log 6 | -------------------------------------------------------------------------------- /myvue/src/assets/book.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qianqia/vue/HEAD/myvue/src/assets/book.jpg -------------------------------------------------------------------------------- /myvue/src/assets/car.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qianqia/vue/HEAD/myvue/src/assets/car.jpg -------------------------------------------------------------------------------- /myvue/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qianqia/vue/HEAD/myvue/src/assets/logo.png -------------------------------------------------------------------------------- /myvue/src/assets/map.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qianqia/vue/HEAD/myvue/src/assets/map.jpg -------------------------------------------------------------------------------- /myvue/src/assets/news.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qianqia/vue/HEAD/myvue/src/assets/news.jpg -------------------------------------------------------------------------------- /myvue/src/assets/user.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qianqia/vue/HEAD/myvue/src/assets/user.jpg -------------------------------------------------------------------------------- /myvue/src/assets/jiantou.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qianqia/vue/HEAD/myvue/src/assets/jiantou.png -------------------------------------------------------------------------------- /myvue/src/assets/top_bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qianqia/vue/HEAD/myvue/src/assets/top_bg.jpg -------------------------------------------------------------------------------- /myvue/src/assets/default_photo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qianqia/vue/HEAD/myvue/src/assets/default_photo.png -------------------------------------------------------------------------------- /myvue/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["latest", { 4 | "es2015": { "modules": false } 5 | }] 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /myvue/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /myvue/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /myvue/src/component/footer.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 11 | 12 | -------------------------------------------------------------------------------- /myvue/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /myvue/src/App.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 20 | 21 | 25 | -------------------------------------------------------------------------------- /myvue/README.md: -------------------------------------------------------------------------------- 1 | # aa 2 | 3 | > A Vue.js project 4 | 5 | ## Build Setup 6 | 7 | ``` bash 8 | # install dependencies 9 | npm install 10 | 11 | # serve with hot reload at localhost:8080 12 | npm run dev 13 | 14 | # build for production with minification 15 | npm run build 16 | ``` 17 | 18 | For detailed explanation on how things work, consult the [docs for vue-loader](http://vuejs.github.io/vue-loader). 19 | -------------------------------------------------------------------------------- /myvue/.idea/myvue.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /myvue/src/js/rem.js: -------------------------------------------------------------------------------- 1 | (function(doc,win){ 2 | var docEl = doc.documentElement,resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize', 3 | recalc = function(){ 4 | var clientWidth = docEl.clientWidth; 5 | if(!clientWidth) return; 6 | if(clientWidth>=640){ 7 | docEl.style.fontSize = '100px'; 8 | } 9 | else{ 10 | docEl.style.fontSize = 100 * (clientWidth / 640) + 'px'; 11 | } 12 | }; 13 | if (!doc.addEventListener) return; 14 | win.addEventListener(resizeEvt, recalc, false); 15 | doc.addEventListener('DOMContentLoaded', recalc, false); 16 | })(document,window); -------------------------------------------------------------------------------- /myvue/src/css/reset.css: -------------------------------------------------------------------------------- 1 | @charset "utf-8"; 2 | /*=========================Reset_start==========================*/ 3 | body,h1,h2,h3,h4,h5,h6,div,p,dl,dt,dd,ol,ul,li,form,table,th,td,a,img,span,strong,var,em,input,textarea,select,option{margin: 0; padding: 0;} 4 | html,body{font-family:"微软雅黑","宋体",Arail,Tabhoma; font-size: 12px; text-align: left;} 5 | ul,ol{list-style: none;} 6 | img{border: 0;} 7 | input,select,textarea{outline:0;} 8 | textarea{resize:none;} 9 | table{border-collapse: collapse; border-spacing: 0;} 10 | th,strong,var,em{font-weight: normal; font-style: normal;} 11 | a{text-decoration: none;} 12 | .fl{float: left} 13 | .fr{float: right} 14 | /*a:link,a:visited,a:hover,a:active{text-decoration:none;} */ 15 | /*==========================Reset_End===========================*/ 16 | -------------------------------------------------------------------------------- /myvue/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | myApp 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /myvue/src/component/active.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 27 | 28 | -------------------------------------------------------------------------------- /myvue/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aa", 3 | "description": "A Vue.js project", 4 | "version": "1.0.0", 5 | "author": "yangwenhui <1185235714@qq.com>", 6 | "private": true, 7 | "scripts": { 8 | "dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot", 9 | "build": "cross-env NODE_ENV=production webpack --progress --hide-modules" 10 | }, 11 | "dependencies": { 12 | "mint-ui": "^2.2.6", 13 | "vue": "^2.2.1" 14 | }, 15 | "devDependencies": { 16 | "axios": "^0.16.1", 17 | "babel-core": "^6.0.0", 18 | "babel-loader": "^6.0.0", 19 | "babel-preset-latest": "^6.0.0", 20 | "cross-env": "^3.0.0", 21 | "css-loader": "^0.25.0", 22 | "file-loader": "^0.9.0", 23 | "style-loader": "^0.17.0", 24 | "vue-awesome-swiper": "^2.4.0", 25 | "vue-loader": "^11.1.4", 26 | "vue-resource": "^1.3.1", 27 | "vue-router": "^2.5.3", 28 | "vue-template-compiler": "^2.2.1", 29 | "webpack": "^2.2.0", 30 | "webpack-dev-server": "^2.2.0" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /myvue/src/component/artical.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 31 | 32 | -------------------------------------------------------------------------------- /myvue/src/component/xiang.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 39 | 40 | -------------------------------------------------------------------------------- /myvue/src/component/round.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 33 | 34 | -------------------------------------------------------------------------------- /myvue/src/json/zaojiao2.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id":10, 4 | "img":"http://img.weiye.me/zcimgdir/thumb/t_148784468858aeb55087573.jpg", 5 | "pro":"你购买寸土寸金的房子,购买高额的奢侈品,你是否能购买到陪伴孩子成长玩乐的欢快时光?你说,工作太过繁忙,你说,人脉需要维护。你是否还在挂念工作手机和酒桌笑谈之外的家人和孩子?我们都知道,努力工作赚钱,可以让孩子获得更好的生活,更优质的教育。但是钱是赚不完的,而孩子的成长之路是条单行道,别让孩子的成长记忆里只留下你埋头工作的背影。忘记你的年终总结,关掉你的客户电话,请利用圣诞节,陪伴孩子来一场冬季里狂欢。待雪花纷飞后,留下满满的暖意和幸福的记忆。在12月24日,远播教育集团将在上海举办首届圣诞亲子嘉年华。让父母和孩子来一场暖彻心怀的亲子大冒险!", 6 | "date":"12月24日", 7 | "local":"云space国际工业设计大秀场(上海市宝山区长逸仙路3000号)", 8 | "company":"远播教育", 9 | "way":"拔打热线电话即可报名", 10 | "zhu":"本活动解释权归远播所有,礼品、集宝袋数量有限,领完为止" 11 | }, 12 | { 13 | "id":11, 14 | "img":"http://img.weiye.me/zcimgdir/thumb/t_148784474358aeb587a167c.jpg", 15 | "pro":"你购买寸土寸金的房子,购买高额的奢侈品,你是否能购买到陪伴孩子成长玩乐的欢快时光?你说,工作太过繁忙,你说,人脉需要维护。你是否还在挂念工作手机和酒桌笑谈之外的家人和孩子?我们都知道,努力工作赚钱,可以让孩子获得更好的生活,更优质的教育。但是钱是赚不完的,而孩子的成长之路是条单行道,别让孩子的成长记忆里只留下你埋头工作的背影。忘记你的年终总结,关掉你的客户电话,请利用圣诞节,陪伴孩子来一场冬季里狂欢。待雪花纷飞后,留下满满的暖意和幸福的记忆。在12月24日,远播教育集团将在上海举办首届圣诞亲子嘉年华。让父母和孩子来一场暖彻心怀的亲子大冒险!", 16 | "date":"12月24日", 17 | "local":"云space国际工业设计大秀场(上海市宝山区长逸仙路3000号)", 18 | "company":"远播教育", 19 | "way":"拔打热线电话即可报名", 20 | "zhu":"本活动解释权归远播所有,礼品、集宝袋数量有限,领完为止" 21 | }, 22 | { 23 | "id":12, 24 | "img":"http://img.weiye.me/zcimgdir/thumb/t_148784476958aeb5a19a2d1.jpg", 25 | "pro":"你购买寸土寸金的房子,购买高额的奢侈品,你是否能购买到陪伴孩子成长玩乐的欢快时光?你说,工作太过繁忙,你说,人脉需要维护。你是否还在挂念工作手机和酒桌笑谈之外的家人和孩子?我们都知道,努力工作赚钱,可以让孩子获得更好的生活,更优质的教育。但是钱是赚不完的,而孩子的成长之路是条单行道,别让孩子的成长记忆里只留下你埋头工作的背影。忘记你的年终总结,关掉你的客户电话,请利用圣诞节,陪伴孩子来一场冬季里狂欢。待雪花纷飞后,留下满满的暖意和幸福的记忆。在12月24日,远播教育集团将在上海举办首届圣诞亲子嘉年华。让父母和孩子来一场暖彻心怀的亲子大冒险!", 26 | "date":"12月24日", 27 | "local":"云space国际工业设计大秀场(上海市宝山区长逸仙路3000号)", 28 | "company":"远播教育", 29 | "way":"拔打热线电话即可报名", 30 | "zhu":"本活动解释权归远播所有,礼品、集宝袋数量有限,领完为止" 31 | } 32 | ] -------------------------------------------------------------------------------- /myvue/src/component/liuyan.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | 31 | 32 | -------------------------------------------------------------------------------- /myvue/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | import Mint from 'mint-ui'; 4 | import 'mint-ui/lib/style.css' 5 | import VueRouter from 'vue-router' 6 | import VueResource from 'vue-resource' 7 | import axios from 'axios' 8 | Vue.use(Mint); 9 | Vue.use(VueRouter) 10 | Vue.use(VueResource) 11 | Vue.use(axios) 12 | 13 | import lun from './component/lun.vue' 14 | import artical from './component/artical.vue' 15 | import artdet from './component/artdet.vue' 16 | 17 | import round from './component/round.vue' 18 | import rdetail from './component/rdetail.vue' 19 | 20 | import active from './component/active.vue' 21 | import xiang from './component/xiang.vue' 22 | 23 | import liuyan from './component/liuyan.vue' 24 | 25 | import my from './component/my.vue' 26 | 27 | import login from './component/login.vue' 28 | import register from './component/register.vue' 29 | import car from './component/car.vue' 30 | 31 | 32 | var route=[ 33 | {path:'/',component:lun, 34 | "children":[ 35 | {path:"/artical",component:artical}, 36 | {path:"/round",component:round}, 37 | 38 | {path:"/",redirect:"/artical"} 39 | ] 40 | }, 41 | 42 | {path:"/my",component:my}, 43 | {path:"/login",component:login}, 44 | {path:'/register',component:register}, 45 | {path:'/car',component:car}, 46 | 47 | {path:'/active',component:active}, 48 | {path:'/liuyan',component:liuyan}, 49 | {path:'/my',component:my}, 50 | {path:'/xiang/:id',component:xiang}, 51 | {path:'/rdetail/:id',component:rdetail}, 52 | {path:'/:id',component:artdet}, 53 | 54 | 55 | 56 | 57 | 58 | ] 59 | 60 | var router=new VueRouter({ 61 | routes:route 62 | }) 63 | 64 | new Vue({ 65 | el: '#app', 66 | router:router, 67 | render: h => h(App) 68 | }) 69 | -------------------------------------------------------------------------------- /myvue/src/component/lun.vue: -------------------------------------------------------------------------------- 1 | 20 | 21 | 39 | 40 | -------------------------------------------------------------------------------- /myvue/src/component/artdet.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 50 | 51 | -------------------------------------------------------------------------------- /myvue/webpack.config.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var webpack = require('webpack') 3 | 4 | module.exports = { 5 | entry: './src/main.js', 6 | output: { 7 | path: path.resolve(__dirname, './dist'), 8 | publicPath: '/dist/', 9 | filename: 'build.js' 10 | }, 11 | module: { 12 | rules: [ 13 | { 14 | test: /\.vue$/, 15 | loader: 'vue-loader', 16 | options: { 17 | loaders: { 18 | } 19 | // other vue-loader options go here 20 | } 21 | }, 22 | { 23 | test: /\.js$/, 24 | loader: 'babel-loader', 25 | exclude: /node_modules/ 26 | }, 27 | { 28 | test: /\.(png|jpg|gif|svg)$/, 29 | loader: 'file-loader', 30 | options: { 31 | name: '[name].[ext]?[hash]' 32 | } 33 | }, 34 | { 35 | test: /\.css$/, 36 | use: [ 37 | { loader: 'style-loader'}, 38 | { 39 | loader: 'css-loader', 40 | options: { 41 | modules: true 42 | } 43 | } 44 | ] 45 | } 46 | ] 47 | }, 48 | resolve: { 49 | alias: { 50 | 'vue$': 'vue/dist/vue.esm.js' 51 | } 52 | }, 53 | devServer: { 54 | historyApiFallback: true, 55 | noInfo: true 56 | }, 57 | performance: { 58 | hints: false 59 | }, 60 | devtool: '#eval-source-map' 61 | } 62 | 63 | if (process.env.NODE_ENV === 'production') { 64 | module.exports.devtool = '#source-map' 65 | // http://vue-loader.vuejs.org/en/workflow/production.html 66 | module.exports.plugins = (module.exports.plugins || []).concat([ 67 | new webpack.DefinePlugin({ 68 | 'process.env': { 69 | NODE_ENV: '"production"' 70 | } 71 | }), 72 | new webpack.optimize.UglifyJsPlugin({ 73 | sourceMap: true, 74 | compress: { 75 | warnings: false 76 | } 77 | }), 78 | new webpack.LoaderOptionsPlugin({ 79 | minimize: true 80 | }) 81 | ]) 82 | } 83 | -------------------------------------------------------------------------------- /myvue/src/component/register.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 64 | 65 | -------------------------------------------------------------------------------- /myvue/src/component/my.vue: -------------------------------------------------------------------------------- 1 | 29 | 30 | 57 | 58 | -------------------------------------------------------------------------------- /myvue/src/component/login.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 62 | 63 | -------------------------------------------------------------------------------- /myvue/src/json/zaojiao1.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id":4, 4 | "title":"转笔刀", 5 | "price":"0.20", 6 | "kucun":"999", 7 | "xliang":"9", 8 | "img":"http://img.weiye.me/zcimgdir/thumb/t_148783898958ae9f0d69c06.jpg", 9 | "zimg":["http://img.weiye.me/zcimgdir/thumb/t_148783898958ae9f0d69c06.jpg","http://img.weiye.me/zcimgdir/thumb/t_148783898958ae9f0d69c06.jpg","http://img.weiye.me/zcimgdir/thumb/t_148783898958ae9f0d69c06.jpg"] 10 | }, 11 | { 12 | "id":5, 13 | "title":"可爱的笔", 14 | "price":"0.20", 15 | "kucun":"999", 16 | "xliang":"9", 17 | "img":"http://img.weiye.me/zcimgdir/album/file_58ae9c291cd32.jpg", 18 | "zimg":["http://img.weiye.me/zcimgdir/thumb/t_148783845658ae9cf8916f5.jpg","http://img.weiye.me/zcimgdir/thumb/t_148783847458ae9d0a1dd46.jpg","http://img.weiye.me/zcimgdir/album/file_58ae9c291cd32.jpg"] 19 | }, 20 | { 21 | "id":6, 22 | "title":"可爱笔记本", 23 | "price":"0.20", 24 | "kucun":"999", 25 | "xliang":"9", 26 | "img":"http://img.weiye.me/zcimgdir/thumb/t_148783826258ae9c361351e.jpg", 27 | "zimg":["http://img.weiye.me/zcimgdir/album/file_58ae9c27ee6c2.jpg","http://img.weiye.me/zcimgdir/album/file_58ae9c2814422.jpg","http://img.weiye.me/zcimgdir/album/file_58ae9c27ee6c2.jpg"] 28 | }, 29 | { 30 | "id":7, 31 | "title":"木质创意铅笔盒", 32 | "price":"0.20", 33 | "kucun":"999", 34 | "xliang":"9", 35 | "img":"http://img.weiye.me/zcimgdir/thumb/t_148783704658ae97762ab8d.jpg", 36 | "zimg":["http://img.weiye.me/zcimgdir/thumb/t_148783704658ae97762ab8d.jpg","http://img.weiye.me/zcimgdir/thumb/t_148783704658ae97762ab8d.jpg","http://img.weiye.me/zcimgdir/thumb/t_148783704658ae97762ab8d.jpg"] 37 | }, 38 | { 39 | "id":8, 40 | "title":"铅笔", 41 | "price":"0.20", 42 | "kucun":"999", 43 | "xliang":"9", 44 | "img":"http://img.weiye.me/zcimgdir/thumb/t_148783699858ae974616f53.jpg", 45 | "zimg":["http://img.weiye.me/zcimgdir/thumb/t_148783699858ae974616f53.jpg","http://img.weiye.me/zcimgdir/thumb/t_148783699858ae974616f53.jpg","http://img.weiye.me/zcimgdir/thumb/t_148783699858ae974616f53.jpg"] 46 | }, 47 | { 48 | "id":9, 49 | "title":"铅笔盒", 50 | "price":"0.20", 51 | "kucun":"999", 52 | "xliang":"9", 53 | "img":"http://img.weiye.me/zcimgdir/thumb/t_148783690758ae96eb9ae26.jpg", 54 | "zimg":["http://img.weiye.me/zcimgdir/thumb/t_148783690758ae96eb9ae26.jpg","http://img.weiye.me/zcimgdir/thumb/t_148783690758ae96eb9ae26.jpg","http://img.weiye.me/zcimgdir/thumb/t_148783690758ae96eb9ae26.jpg"] 55 | } 56 | ] -------------------------------------------------------------------------------- /myvue/src/component/car.vue: -------------------------------------------------------------------------------- 1 | 20 | 21 | 66 | 67 | -------------------------------------------------------------------------------- /myvue/src/component/ymain.vue: -------------------------------------------------------------------------------- 1 | 41 | 42 | 74 | 75 | -------------------------------------------------------------------------------- /myvue/src/component/rdetail.vue: -------------------------------------------------------------------------------- 1 | 32 | 33 | 95 | 96 | -------------------------------------------------------------------------------- /myvue/src/json/zaojiao.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id":0, 4 | "title":"生活重的言传身教,帮助孩子养成好习惯", 5 | "sname":[">>>>习惯一:做事有计划",">>>>习惯二:讲道理,善待他人",">>>>习惯三:自己的事自己做"], 6 | "img":"http://img.weiye.me/zcimgdir/album/file_58ad5fb1d320d.png", 7 | "cimg":["http://img.weiye.me/zcimgdir/album/file_58ad5fb1d320d.png","http://img.weiye.me/zcimgdir/thumb/t_148784219358aeab91c90ff.png","http://img.weiye.me/zcimgdir/thumb/t_148784236458aeac3cdb705.png","http://img.weiye.me/zcimgdir/thumb/t_148784250858aeacccecb26.png"], 8 | "product":["孩子从小养成好习惯会受用终生,因为这些习惯关乎到孩子今后的发展。好 习惯让孩子一辈子都享受不尽它的利息,坏习惯让一辈子都偿还不尽它的债 务……请爸爸妈妈以身作则,在年幼阶段,教会孩子养成这七个好习惯, 长大就迟了。作家冯唐曾说,成功没有捷径,但需要一些好习惯。的确,如果将人的各种命运分解、揉碎,试图从中找出一些规律的话,那么良好的习惯,敢于抓住际遇的勇气是比天赋更为重要的东西。而幼年是养成好习惯的最佳时期,这时的孩子就像一张白纸,如果能在家长的引导下养成好习惯,就能在这张白纸上慢慢展现美妙的图画,而不是乱七八糟的笔划。", 9 | "每个人都愿意面对一张微笑的脸。微笑待人的人,总是真诚友善、宽容大度,他们走到哪里都会是受欢迎的人。平时多关心他人……长久以往,孩子会收获到比礼貌更有意义的人生财富。有这样的一个故事:有一个孩子每天上学时,会主动跟看门的老爷爷打招呼。别的孩子都没有这样的行为,这让老爷爷对他印象深刻。有一天上课铃声响起,老爷爷没等到那个孩子,不由得有些担心。正当老爷爷走到路口瞧瞧时,恰好看到一个男人正对那个孩子拉拉扯扯,想把他拖进面包车。老爷爷急忙冲过去,制止了坏人的行为,解救了孩子。可想而知,正是孩子对老爷爷平时的礼貌行为,才让自己保命", 10 | "做事有计划的人才会赢得信任,不至于临时抱佛脚。有些孩子每次考试前就一团乱麻,做作业时三心二意,早晨起床上学常常找不到袜子,零用钱花不到月底就一分不剩……当孩子有这方面的坏毛病时,一定教会他懂得计划的重要性。不妨让孩子在睡前梳理好第二天的日程,让孩子抄在便利贴上方便执行。养成这个好习惯,孩子绝对终生受益!", 11 | "很多家长怕把事情交给孩子做的话,孩子会搞砸,可是谁第一次做事不是迷迷糊糊的呢?多给他一些尝试的机会,慢慢地,你会发现孩子的能力超乎你的想象!请让孩子养成“自己的事自己做”的好习惯。在孩子学会自理之前,父母要做的是放手。特别在孩子进入小学后,起床问题,叠被子,整理房间,收拾书包等这些事情就不要再为孩子包办了。爸爸妈妈可以为孩子举办“小仪式”庆祝孩子的长大,然后提醒孩子:你现在走进小学,已经是小大人,以后自己的事情自己做,爸爸妈妈相信你能做好。给孩子金山银山,不如给孩子一个好习惯。在孩子的幼年时期,让孩子养成一些好习惯,对他的成长甚至一生都会产生重要作用。一般说来,一个习惯的养成至少需要21天,“冰冻三尺非一日之寒,滴水石穿非一日之功”。同样地,这些习惯对我们大人也很适用,引导帮助孩子的同时,我们也一起来提升吧!"] 12 | }, 13 | { 14 | "id":1, 15 | "title":"如何培养孩子的动手能力", 16 | "sname":[">>>>习惯一:做事有计划",">>>>习惯二:讲道理,善待他人",">>>>习惯三:自己的事自己做"], 17 | "img":"http://img.weiye.me/zcimgdir/album/file_58ad62828ed57.png", 18 | "cimg":["http://img.weiye.me/zcimgdir/album/file_58ad62828ed57.png","http://img.weiye.me/zcimgdir/thumb/t_148784219358aeab91c90ff.png","http://img.weiye.me/zcimgdir/thumb/t_148784236458aeac3cdb705.png","http://img.weiye.me/zcimgdir/thumb/t_148784250858aeacccecb26.png"], 19 | "product":["孩子从小养成好习惯会受用终生,因为这些习惯关乎到孩子今后的发展。好 习惯让孩子一辈子都享受不尽它的利息,坏习惯让一辈子都偿还不尽它的债 务……请爸爸妈妈以身作则,在年幼阶段,教会孩子养成这七个好习惯, 长大就迟了。作家冯唐曾说,成功没有捷径,但需要一些好习惯。的确,如果将人的各种命运分解、揉碎,试图从中找出一些规律的话,那么良好的习惯,敢于抓住际遇的勇气是比天赋更为重要的东西。而幼年是养成好习惯的最佳时期,这时的孩子就像一张白纸,如果能在家长的引导下养成好习惯,就能在这张白纸上慢慢展现美妙的图画,而不是乱七八糟的笔划。", 20 | "每个人都愿意面对一张微笑的脸。微笑待人的人,总是真诚友善、宽容大度,他们走到哪里都会是受欢迎的人。平时多关心他人……长久以往,孩子会收获到比礼貌更有意义的人生财富。有这样的一个故事:有一个孩子每天上学时,会主动跟看门的老爷爷打招呼。别的孩子都没有这样的行为,这让老爷爷对他印象深刻。有一天上课铃声响起,老爷爷没等到那个孩子,不由得有些担心。正当老爷爷走到路口瞧瞧时,恰好看到一个男人正对那个孩子拉拉扯扯,想把他拖进面包车。老爷爷急忙冲过去,制止了坏人的行为,解救了孩子。可想而知,正是孩子对老爷爷平时的礼貌行为,才让自己保命", 21 | "做事有计划的人才会赢得信任,不至于临时抱佛脚。有些孩子每次考试前就一团乱麻,做作业时三心二意,早晨起床上学常常找不到袜子,零用钱花不到月底就一分不剩……当孩子有这方面的坏毛病时,一定教会他懂得计划的重要性。不妨让孩子在睡前梳理好第二天的日程,让孩子抄在便利贴上方便执行。养成这个好习惯,孩子绝对终生受益!", 22 | "很多家长怕把事情交给孩子做的话,孩子会搞砸,可是谁第一次做事不是迷迷糊糊的呢?多给他一些尝试的机会,慢慢地,你会发现孩子的能力超乎你的想象!请让孩子养成“自己的事自己做”的好习惯。在孩子学会自理之前,父母要做的是放手。特别在孩子进入小学后,起床问题,叠被子,整理房间,收拾书包等这些事情就不要再为孩子包办了。爸爸妈妈可以为孩子举办“小仪式”庆祝孩子的长大,然后提醒孩子:你现在走进小学,已经是小大人,以后自己的事情自己做,爸爸妈妈相信你能做好。给孩子金山银山,不如给孩子一个好习惯。在孩子的幼年时期,让孩子养成一些好习惯,对他的成长甚至一生都会产生重要作用。一般说来,一个习惯的养成至少需要21天,“冰冻三尺非一日之寒,滴水石穿非一日之功”。同样地,这些习惯对我们大人也很适用,引导帮助孩子的同时,我们也一起来提升吧!"] 23 | }, 24 | { 25 | "id":2, 26 | "title":"小孩早期智力开发的思考", 27 | "sname":[">>>>习惯一:做事有计划",">>>>习惯二:讲道理,善待他人",">>>>习惯三:自己的事自己做"], 28 | "img":"http://img.weiye.me/zcimgdir/album/file_58ad6282a2b8e.png", 29 | "cimg":["http://img.weiye.me/zcimgdir/album/file_58ad6282a2b8e.png","http://img.weiye.me/zcimgdir/thumb/t_148784219358aeab91c90ff.png","http://img.weiye.me/zcimgdir/thumb/t_148784236458aeac3cdb705.png","http://img.weiye.me/zcimgdir/thumb/t_148784250858aeacccecb26.png"], 30 | "product":["孩子从小养成好习惯会受用终生,因为这些习惯关乎到孩子今后的发展。好 习惯让孩子一辈子都享受不尽它的利息,坏习惯让一辈子都偿还不尽它的债 务……请爸爸妈妈以身作则,在年幼阶段,教会孩子养成这七个好习惯, 长大就迟了。作家冯唐曾说,成功没有捷径,但需要一些好习惯。的确,如果将人的各种命运分解、揉碎,试图从中找出一些规律的话,那么良好的习惯,敢于抓住际遇的勇气是比天赋更为重要的东西。而幼年是养成好习惯的最佳时期,这时的孩子就像一张白纸,如果能在家长的引导下养成好习惯,就能在这张白纸上慢慢展现美妙的图画,而不是乱七八糟的笔划。", 31 | "每个人都愿意面对一张微笑的脸。微笑待人的人,总是真诚友善、宽容大度,他们走到哪里都会是受欢迎的人。平时多关心他人……长久以往,孩子会收获到比礼貌更有意义的人生财富。有这样的一个故事:有一个孩子每天上学时,会主动跟看门的老爷爷打招呼。别的孩子都没有这样的行为,这让老爷爷对他印象深刻。有一天上课铃声响起,老爷爷没等到那个孩子,不由得有些担心。正当老爷爷走到路口瞧瞧时,恰好看到一个男人正对那个孩子拉拉扯扯,想把他拖进面包车。老爷爷急忙冲过去,制止了坏人的行为,解救了孩子。可想而知,正是孩子对老爷爷平时的礼貌行为,才让自己保命", 32 | "做事有计划的人才会赢得信任,不至于临时抱佛脚。有些孩子每次考试前就一团乱麻,做作业时三心二意,早晨起床上学常常找不到袜子,零用钱花不到月底就一分不剩……当孩子有这方面的坏毛病时,一定教会他懂得计划的重要性。不妨让孩子在睡前梳理好第二天的日程,让孩子抄在便利贴上方便执行。养成这个好习惯,孩子绝对终生受益!", 33 | "很多家长怕把事情交给孩子做的话,孩子会搞砸,可是谁第一次做事不是迷迷糊糊的呢?多给他一些尝试的机会,慢慢地,你会发现孩子的能力超乎你的想象!请让孩子养成“自己的事自己做”的好习惯。在孩子学会自理之前,父母要做的是放手。特别在孩子进入小学后,起床问题,叠被子,整理房间,收拾书包等这些事情就不要再为孩子包办了。爸爸妈妈可以为孩子举办“小仪式”庆祝孩子的长大,然后提醒孩子:你现在走进小学,已经是小大人,以后自己的事情自己做,爸爸妈妈相信你能做好。给孩子金山银山,不如给孩子一个好习惯。在孩子的幼年时期,让孩子养成一些好习惯,对他的成长甚至一生都会产生重要作用。一般说来,一个习惯的养成至少需要21天,“冰冻三尺非一日之寒,滴水石穿非一日之功”。同样地,这些习惯对我们大人也很适用,引导帮助孩子的同时,我们也一起来提升吧!"] 34 | } 35 | ] 36 | -------------------------------------------------------------------------------- /myvue/src/js/axios.min.js: -------------------------------------------------------------------------------- 1 | /* axios v0.15.3 | (c) 2016 by Matt Zabriskie */ 2 | !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.axios=t():e.axios=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";function r(e){var t=new i(e),n=s(i.prototype.request,t);return o.extend(n,i.prototype,t),o.extend(n,t),n}var o=n(2),s=n(3),i=n(4),a=n(5),u=r(a);u.Axios=i,u.create=function(e){return r(o.merge(a,e))},u.Cancel=n(22),u.CancelToken=n(23),u.isCancel=n(19),u.all=function(e){return Promise.all(e)},u.spread=n(24),e.exports=u,e.exports.default=u},function(e,t,n){"use strict";function r(e){return"[object Array]"===C.call(e)}function o(e){return"[object ArrayBuffer]"===C.call(e)}function s(e){return"undefined"!=typeof FormData&&e instanceof FormData}function i(e){var t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function a(e){return"string"==typeof e}function u(e){return"number"==typeof e}function c(e){return"undefined"==typeof e}function f(e){return null!==e&&"object"==typeof e}function p(e){return"[object Date]"===C.call(e)}function d(e){return"[object File]"===C.call(e)}function l(e){return"[object Blob]"===C.call(e)}function h(e){return"[object Function]"===C.call(e)}function m(e){return f(e)&&h(e.pipe)}function y(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams}function w(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function g(){return"undefined"!=typeof window&&"undefined"!=typeof document&&"function"==typeof document.createElement}function v(e,t){if(null!==e&&"undefined"!=typeof e)if("object"==typeof e||r(e)||(e=[e]),r(e))for(var n=0,o=e.length;n=200&&e<300}};c.headers={common:{Accept:"application/json, text/plain, */*"}},s.forEach(["delete","get","head"],function(e){c.headers[e]={}}),s.forEach(["post","put","patch"],function(e){c.headers[e]=s.merge(u)}),e.exports=c},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t){r.forEach(e,function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])})}},function(e,t,n){"use strict";var r=n(2),o=n(8),s=n(11),i=n(12),a=n(13),u=n(9),c="undefined"!=typeof window&&window.btoa&&window.btoa.bind(window)||n(14);e.exports=function(e){return new Promise(function(t,f){var p=e.data,d=e.headers;r.isFormData(p)&&delete d["Content-Type"];var l=new XMLHttpRequest,h="onreadystatechange",m=!1;if("undefined"==typeof window||!window.XDomainRequest||"withCredentials"in l||a(e.url)||(l=new window.XDomainRequest,h="onload",m=!0,l.onprogress=function(){},l.ontimeout=function(){}),e.auth){var y=e.auth.username||"",w=e.auth.password||"";d.Authorization="Basic "+c(y+":"+w)}if(l.open(e.method.toUpperCase(),s(e.url,e.params,e.paramsSerializer),!0),l.timeout=e.timeout,l[h]=function(){if(l&&(4===l.readyState||m)&&(0!==l.status||l.responseURL&&0===l.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in l?i(l.getAllResponseHeaders()):null,r=e.responseType&&"text"!==e.responseType?l.response:l.responseText,s={data:r,status:1223===l.status?204:l.status,statusText:1223===l.status?"No Content":l.statusText,headers:n,config:e,request:l};o(t,f,s),l=null}},l.onerror=function(){f(u("Network Error",e)),l=null},l.ontimeout=function(){f(u("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED")),l=null},r.isStandardBrowserEnv()){var g=n(15),v=(e.withCredentials||a(e.url))&&e.xsrfCookieName?g.read(e.xsrfCookieName):void 0;v&&(d[e.xsrfHeaderName]=v)}if("setRequestHeader"in l&&r.forEach(d,function(e,t){"undefined"==typeof p&&"content-type"===t.toLowerCase()?delete d[t]:l.setRequestHeader(t,e)}),e.withCredentials&&(l.withCredentials=!0),e.responseType)try{l.responseType=e.responseType}catch(e){if("json"!==l.responseType)throw e}"function"==typeof e.onDownloadProgress&&l.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&l.upload&&l.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){l&&(l.abort(),f(e),l=null)}),void 0===p&&(p=null),l.send(p)})}},function(e,t,n){"use strict";var r=n(9);e.exports=function(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n)):e(n)}},function(e,t,n){"use strict";var r=n(10);e.exports=function(e,t,n,o){var s=new Error(e);return r(s,t,n,o)}},function(e,t){"use strict";e.exports=function(e,t,n,r){return e.config=t,n&&(e.code=n),e.response=r,e}},function(e,t,n){"use strict";function r(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var o=n(2);e.exports=function(e,t,n){if(!t)return e;var s;if(n)s=n(t);else if(o.isURLSearchParams(t))s=t.toString();else{var i=[];o.forEach(t,function(e,t){null!==e&&"undefined"!=typeof e&&(o.isArray(e)&&(t+="[]"),o.isArray(e)||(e=[e]),o.forEach(e,function(e){o.isDate(e)?e=e.toISOString():o.isObject(e)&&(e=JSON.stringify(e)),i.push(r(t)+"="+r(e))}))}),s=i.join("&")}return s&&(e+=(e.indexOf("?")===-1?"?":"&")+s),e}},function(e,t,n){"use strict";var r=n(2);e.exports=function(e){var t,n,o,s={};return e?(r.forEach(e.split("\n"),function(e){o=e.indexOf(":"),t=r.trim(e.substr(0,o)).toLowerCase(),n=r.trim(e.substr(o+1)),t&&(s[t]=s[t]?s[t]+", "+n:n)}),s):s}},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){function e(e){var t=e;return n&&(o.setAttribute("href",t),t=o.href),o.setAttribute("href",t),{href:o.href,protocol:o.protocol?o.protocol.replace(/:$/,""):"",host:o.host,search:o.search?o.search.replace(/^\?/,""):"",hash:o.hash?o.hash.replace(/^#/,""):"",hostname:o.hostname,port:o.port,pathname:"/"===o.pathname.charAt(0)?o.pathname:"/"+o.pathname}}var t,n=/(msie|trident)/i.test(navigator.userAgent),o=document.createElement("a");return t=e(window.location.href),function(n){var o=r.isString(n)?e(n):n;return o.protocol===t.protocol&&o.host===t.host}}():function(){return function(){return!0}}()},function(e,t){"use strict";function n(){this.message="String contains an invalid character"}function r(e){for(var t,r,s=String(e),i="",a=0,u=o;s.charAt(0|a)||(u="=",a%1);i+=u.charAt(63&t>>8-a%1*8)){if(r=s.charCodeAt(a+=.75),r>255)throw new n;t=t<<8|r}return i}var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.prototype=new Error,n.prototype.code=5,n.prototype.name="InvalidCharacterError",e.exports=r},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){return{write:function(e,t,n,o,s,i){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(o)&&a.push("path="+o),r.isString(s)&&a.push("domain="+s),i===!0&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(e,t,n){"use strict";function r(){this.handlers=[]}var o=n(2);r.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},r.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},r.prototype.forEach=function(e){o.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=r},function(e,t,n){"use strict";function r(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var o=n(2),s=n(18),i=n(19),a=n(5);e.exports=function(e){r(e),e.headers=e.headers||{},e.data=s(e.data,e.headers,e.transformRequest),e.headers=o.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),o.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]});var t=e.adapter||a.adapter;return t(e).then(function(t){return r(e),t.data=s(t.data,t.headers,e.transformResponse),t},function(t){return i(t)||(r(e),t&&t.response&&(t.response.data=s(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})}},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t,n){return r.forEach(n,function(n){e=n(e,t)}),e}},function(e,t){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t){"use strict";e.exports=function(e,t){return e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,"")}},function(e,t){"use strict";function n(e){this.message=e}n.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},n.prototype.__CANCEL__=!0,e.exports=n},function(e,t,n){"use strict";function r(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var n=this;e(function(e){n.reason||(n.reason=new o(e),t(n.reason))})}var o=n(22);r.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},r.source=function(){var e,t=new r(function(t){e=t});return{token:t,cancel:e}},e.exports=r},function(e,t){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}}])}); 3 | //# sourceMappingURL=axios.min.map -------------------------------------------------------------------------------- /myvue/src/js/touch.min.js: -------------------------------------------------------------------------------- 1 | /*! touchjs.min v0.2.14 2014-08-05 */ 2 | "use strict";!function(a,b){"function"==typeof define&&(define.amd||define.cmd)?define(b):a.touch=b()}(this,function(){function a(){var a="mouseup mousedown mousemove mouseout",c="touchstart touchmove touchend touchcancel",d=b.hasTouch?c:a;d.split(" ").forEach(function(a){document.addEventListener(a,A,!1)})}var b={};b.PCevts={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",touchcancel:"mouseout"},b.hasTouch="ontouchstart"in window,b.getType=function(a){return Object.prototype.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()},b.getSelector=function(a){if(a.id)return"#"+a.id;if(a.className){var b=a.className.split(/\s+/);return"."+b.join(".")}return a===document?"body":a.tagName.toLowerCase()},b.matchSelector=function(a,b){return a.webkitMatchesSelector(b)},b.getEventListeners=function(a){return a.listeners},b.getPCevts=function(a){return this.PCevts[a]||a},b.forceReflow=function(){var a="reflowDivBlock",b=document.getElementById(a);b||(b=document.createElement("div"),b.id=a,document.body.appendChild(b));var c=b.parentNode,d=b.nextSibling;c.removeChild(b),c.insertBefore(b,d)},b.simpleClone=function(a){return Object.create(a)},b.getPosOfEvent=function(a){if(this.hasTouch){for(var b=[],c=null,d=0,e=a.touches.length;e>d;d++)c=a.touches[d],b.push({x:c.pageX,y:c.pageY});return b}return[{x:a.pageX,y:a.pageY}]},b.getDistance=function(a,b){var c=b.x-a.x,d=b.y-a.y;return Math.sqrt(c*c+d*d)},b.getFingers=function(a){return a.touches?a.touches.length:1},b.calScale=function(a,b){if(a.length>=2&&b.length>=2){var c=this.getDistance(a[1],a[0]),d=this.getDistance(b[1],b[0]);return d/c}return 1},b.getAngle=function(a,b){return 180*Math.atan2(b.y-a.y,b.x-a.x)/Math.PI},b.getAngle180=function(a,b){var c=Math.atan(-1*(b.y-a.y)/(b.x-a.x))*(180/Math.PI);return 0>c?c+180:c},b.getDirectionFromAngle=function(a){var b={up:-45>a&&a>-135,down:a>=45&&135>a,left:a>=135||-135>=a,right:a>=-45&&45>=a};for(var c in b)if(b[c])return c;return null},b.getXYByElement=function(a){for(var b=0,c=0;a.offsetParent;)b+=a.offsetLeft,c+=a.offsetTop,a=a.offsetParent;return{left:b,top:c}},b.reset=function(){h=i=j=null,q=o=k=l=!1,m=!1,f={},t=!1},b.isTouchMove=function(a){return"touchmove"===a.type||"mousemove"===a.type},b.isTouchEnd=function(a){return"touchend"===a.type||"mouseup"===a.type||"touchcancel"===a.type},b.env=function(){var a={},b=navigator.userAgent,c=b.match(/(Android)[\s\/]+([\d\.]+)/),d=b.match(/(iPad|iPhone|iPod)\s+OS\s([\d_\.]+)/),e=b.match(/(Windows\s+Phone)\s([\d\.]+)/),f=/WebKit\/[\d.]+/i.test(b),g=d?navigator.standalone?f:/Safari/i.test(b)&&!/CriOS/i.test(b)&&!/MQQBrowser/i.test(b):!1;return c&&(a.android=!0,a.version=c[2]),d&&(a.ios=!0,a.version=d[2].replace(/_/g,"."),a.ios7=/^7/.test(a.version),"iPad"===d[1]?a.ipad=!0:"iPhone"===d[1]?(a.iphone=!0,a.iphone5=568==screen.height):"iPod"===d[1]&&(a.ipod=!0)),e&&(a.wp=!0,a.version=e[2],a.wp8=/^8/.test(a.version)),f&&(a.webkit=!0),g&&(a.safari=!0),a}();var c={proxyid:0,proxies:[],trigger:function(a,b,c){c=c||{};var d,e={bubbles:!0,cancelable:!0,detail:c};try{"undefined"!=typeof CustomEvent?(d=new CustomEvent(b,e),a&&a.dispatchEvent(d)):(d=document.createEvent("CustomEvent"),d.initCustomEvent(b,!0,!0,c),a&&a.dispatchEvent(d))}catch(f){console.warn("Touch.js is not supported by environment.")}},bind:function(a,c,d){a.listeners=a.listeners||{},a.listeners[c]?a.listeners[c].push(d):a.listeners[c]=[d];var e=function(a){b.env.ios7&&b.forceReflow(),a.originEvent=a;for(var c in a.detail)"type"!==c&&(a[c]=a.detail[c]);a.startRotate=function(){t=!0};var e=d.call(a.target,a);"undefined"==typeof e||e||(a.stopPropagation(),a.preventDefault())};d.proxy=d.proxy||{},d.proxy[c]?d.proxy[c].push(this.proxyid++):d.proxy[c]=[this.proxyid++],this.proxies.push(e),a.addEventListener&&a.addEventListener(c,e,!1)},unbind:function(a,b,c){if(c){var d=c.proxy[b];d&&d.length&&d.forEach(function(){a.removeEventListener&&a.removeEventListener(b,this.proxies[this.proxyid],!1)})}else{var e=a.listeners[b];e&&e.length&&e.forEach(function(c){a.removeEventListener(b,c,!1)})}},delegate:function(a,c,d,e){var f=function(c){var f,g;c.originEvent=c;for(var h in c.detail)"type"!==h&&(c[h]=c.detail[h]);c.startRotate=function(){t=!0};var i=b.getSelector(a)+" "+d,j=b.matchSelector(c.target,i),k=b.matchSelector(c.target,i+" "+c.target.nodeName);if(!j&&k){for(b.env.ios7&&b.forceReflow(),f=c.target;!b.matchSelector(f,i);)f=f.parentNode;g=e.call(c.target,c),"undefined"==typeof g||g||(c.stopPropagation(),c.preventDefault())}else b.env.ios7&&b.forceReflow(),(j||k)&&(g=e.call(c.target,c),"undefined"==typeof g||g||(c.stopPropagation(),c.preventDefault()))};e.proxy=e.proxy||{},e.proxy[c]?e.proxy[c].push(this.proxyid++):e.proxy[c]=[this.proxyid++],this.proxies.push(f),a.listeners=a.listeners||{},a.listeners[c]?a.listeners[c].push(f):a.listeners[c]=[f],a.addEventListener&&a.addEventListener(c,f,!1)},undelegate:function(a,b,c,d){if(d){var e=d.proxy[b];e.length&&e.forEach(function(){a.removeEventListener&&a.removeEventListener(b,this.proxies[this.proxyid],!1)})}else{var f=a.listeners[b];f.forEach(function(c){a.removeEventListener(b,c,!1)})}}},d={tap:!0,doubleTap:!0,tapMaxDistance:10,hold:!0,tapTime:200,holdTime:650,maxDoubleTapInterval:300,swipe:!0,swipeTime:300,swipeMinDistance:18,swipeFactor:5,drag:!0,pinch:!0,minScaleRate:0,minRotationAngle:0},e={TOUCH_START:"touchstart",TOUCH_MOVE:"touchmove",TOUCH_END:"touchend",TOUCH_CANCEL:"touchcancel",MOUSE_DOWN:"mousedown",MOUSE_MOVE:"mousemove",MOUSE_UP:"mouseup",CLICK:"click",PINCH_START:"pinchstart",PINCH_END:"pinchend",PINCH:"pinch",PINCH_IN:"pinchin",PINCH_OUT:"pinchout",ROTATION_LEFT:"rotateleft",ROTATION_RIGHT:"rotateright",ROTATION:"rotate",SWIPE_START:"swipestart",SWIPING:"swiping",SWIPE_END:"swipeend",SWIPE_LEFT:"swipeleft",SWIPE_RIGHT:"swiperight",SWIPE_UP:"swipeup",SWIPE_DOWN:"swipedown",SWIPE:"swipe",DRAG:"drag",DRAGSTART:"dragstart",DRAGEND:"dragend",HOLD:"hold",TAP:"tap",DOUBLE_TAP:"doubletap"},f={start:null,move:null,end:null},g=0,h=null,i=null,j=null,k=!1,l=!1,m=!1,n={},o=!1,p=null,q=!1,r=null,s=1,t=!1,u=[],v=0,w=0,x=0,y=null,z={getAngleDiff:function(a){for(var c=parseInt(v-b.getAngle180(a[0],a[1]),10),d=0;Math.abs(c-w)>90&&d++<50;)0>w?c-=180:c+=180;return w=parseInt(c,10)},pinch:function(a){var g=a.target;if(d.pinch){if(!o)return;if(b.getFingers(a)<2&&!b.isTouchEnd(a))return;var h=b.calScale(f.start,f.move),i=this.getAngleDiff(f.move),j={type:"",originEvent:a,scale:h,rotation:i,direction:i>0?"right":"left",fingersCount:b.getFingers(a)};if(l?b.isTouchMove(a)?(j.fingerStatus="move",c.trigger(g,e.PINCH,j)):b.isTouchEnd(a)&&(j.fingerStatus="end",c.trigger(g,e.PINCH_END,j),b.reset()):(l=!0,j.fingerStatus="start",c.trigger(g,e.PINCH_START,j)),Math.abs(1-h)>d.minScaleRate){var k=b.simpleClone(j),m=1e-11;h>s?(s=h-m,c.trigger(g,e.PINCH_OUT,k,!1)):s>h&&(s=h+m,c.trigger(g,e.PINCH_IN,k,!1)),b.isTouchEnd(a)&&(s=1)}if(Math.abs(i)>d.minRotationAngle){var n,p=b.simpleClone(j);n=i>0?e.ROTATION_RIGHT:e.ROTATION_LEFT,c.trigger(g,n,p,!1),c.trigger(g,e.ROTATION,j)}}},rotateSingleFinger:function(a){var d=a.target;if(t&&b.getFingers(a)<2){if(!f.move)return;if(u.length<2){var g=b.getXYByElement(d);u=[{x:g.left+d.offsetWidth/2,y:g.top+d.offsetHeight/2},f.move[0]],v=parseInt(b.getAngle180(u[0],u[1]),10)}var h=[u[0],f.move[0]],i=this.getAngleDiff(h),j={type:"",originEvent:a,rotation:i,direction:i>0?"right":"left",fingersCount:b.getFingers(a)};b.isTouchMove(a)?j.fingerStatus="move":(b.isTouchEnd(a)||"mouseout"===a.type)&&(j.fingerStatus="end",c.trigger(d,e.PINCH_END,j),b.reset());var k=i>0?e.ROTATION_RIGHT:e.ROTATION_LEFT;c.trigger(d,k,j),c.trigger(d,e.ROTATION,j)}},swipe:function(a){var h=a.target;if(o&&f.move&&!(b.getFingers(a)>1)){var i=Date.now(),j=i-g,l=b.getDistance(f.start[0],f.move[0]),p={x:f.move[0].x-n.left,y:f.move[0].y-n.top},q=b.getAngle(f.start[0],f.move[0]),r=b.getDirectionFromAngle(q),s=j/1e3,t=10*(10-d.swipeFactor)*s*s,u={type:e.SWIPE,originEvent:a,position:p,direction:r,distance:l,distanceX:f.move[0].x-f.start[0].x,distanceY:f.move[0].y-f.start[0].y,x:f.move[0].x-f.start[0].x,y:f.move[0].y-f.start[0].y,angle:q,duration:j,fingersCount:b.getFingers(a),factor:t};if(d.swipe){var v=function(){var a=e;switch(r){case"up":c.trigger(h,a.SWIPE_UP,u);break;case"down":c.trigger(h,a.SWIPE_DOWN,u);break;case"left":c.trigger(h,a.SWIPE_LEFT,u);break;case"right":c.trigger(h,a.SWIPE_RIGHT,u)}};k?b.isTouchMove(a)?(u.fingerStatus=u.swipe="move",c.trigger(h,e.SWIPING,u),j>d.swipeTime&&jd.swipeMinDistance&&(v(),c.trigger(h,e.SWIPE,u,!1))):(b.isTouchEnd(a)||"mouseout"===a.type)&&(u.fingerStatus=u.swipe="end",c.trigger(h,e.SWIPE_END,u),d.swipeTime>j&&l>d.swipeMinDistance&&(v(),c.trigger(h,e.SWIPE,u,!1))):(u.fingerStatus=u.swipe="start",k=!0,c.trigger(h,e.SWIPE_START,u))}d.drag&&(m?b.isTouchMove(a)?(u.fingerStatus=u.swipe="move",c.trigger(h,e.DRAG,u)):b.isTouchEnd(a)&&(u.fingerStatus=u.swipe="end",c.trigger(h,e.DRAGEND,u)):(u.fingerStatus=u.swipe="start",m=!0,c.trigger(h,e.DRAGSTART,u)))}},tap:function(a){var h=a.target;if(d.tap){var i=Date.now(),j=i-g,k=b.getDistance(f.start[0],f.move?f.move[0]:f.start[0]);clearTimeout(p);var l=function(){if(y&&d.doubleTap&&g-xa)return!0}return!1}();if(l)return clearTimeout(r),void c.trigger(h,e.DOUBLE_TAP,{type:e.DOUBLE_TAP,originEvent:a,position:f.start[0]});if(d.tapMaxDistancej&&b.getFingers(a)<=1&&(q=!0,x=i,y=f.start[0],r=setTimeout(function(){c.trigger(h,e.TAP,{type:e.TAP,originEvent:a,fingersCount:b.getFingers(a),position:y})},d.tapTime))}},hold:function(a){var e=a.target;d.hold&&(clearTimeout(p),p=setTimeout(function(){if(f.start){var g=b.getDistance(f.start[0],f.move?f.move[0]:f.start[0]);d.tapMaxDistance=2&&(v=parseInt(b.getAngle180(f.start[0],f.start[1]),10)),g=Date.now(),h=a,n={};var d=c.getBoundingClientRect(),e=document.documentElement;n={top:d.top+(window.pageYOffset||e.scrollTop)-(e.clientTop||0),left:d.left+(window.pageXOffset||e.scrollLeft)-(e.clientLeft||0)},z.hold(a);break;case"touchmove":case"mousemove":if(!o||!f.start)return;f.move=b.getPosOfEvent(a),b.getFingers(a)>=2?z.pinch(a):t?z.rotateSingleFinger(a):z.swipe(a);break;case"touchend":case"touchcancel":case"mouseup":case"mouseout":if(!o)return;j=a,l?z.pinch(a):t?z.rotateSingleFinger(a):k?z.swipe(a):z.tap(a),b.reset(),v=0,w=0,a.touches&&1===a.touches.length&&(o=!0,t=!0)}},B=function(){function a(a){b.hasTouch||(a=b.getPCevts(a)),j.forEach(function(b){c.delegate(b,a,h,g[a])})}function d(a){b.hasTouch||(a=b.getPCevts(a)),j.forEach(function(b){c.bind(b,a,g[a])})}var e,f,g,h,i=arguments;if(i.length<2||i>4)return console.error("unexpected arguments!");var j="string"===b.getType(i[0])?document.querySelectorAll(i[0]):i[0];if(j=j.length?Array.prototype.slice.call(j):[j],3===i.length&&"string"===b.getType(i[1]))return e=i[1].split(" "),f=i[2],void e.forEach(function(a){b.hasTouch||(a=b.getPCevts(a)),j.forEach(function(b){c.bind(b,a,f)})});if(3!==i.length||"object"!==b.getType(i[1]))if(2!==i.length||"object"!==b.getType(i[1])){if(4===i.length&&"object"===b.getType(i[2]))return e=i[1].split(" "),f=i[3],void e.forEach(function(a){b.hasTouch||(a=b.getPCevts(a)),j.forEach(function(b){c.bind(b,a,f)})});if(4===i.length){var k=j[0];return e=i[1].split(" "),h=i[2],f=i[3],void e.forEach(function(a){b.hasTouch||(a=b.getPCevts(a)),c.delegate(k,a,h,f)})}}else{g=i[1];for(var l in g)d(l)}else{g=i[1],h=i[2];for(var m in g)a(m)}},C=function(){var a,d,e=arguments;if(e.length<1||e.length>4)return console.error("unexpected arguments!");var f="string"===b.getType(e[0])?document.querySelectorAll(e[0]):e[0];if(f=f.length?Array.prototype.slice.call(f):[f],1===e.length||2===e.length)return void f.forEach(function(d){a=e[1]?e[1].split(" "):Object.keys(d.listeners),a.length&&a.forEach(function(a){b.hasTouch||(a=b.getPCevts(a)),c.unbind(d,a),c.undelegate(d,a)})});if(3===e.length&&"function"===b.getType(e[2]))return d=e[2],void f.forEach(function(f){a=e[1].split(" "),a.forEach(function(a){b.hasTouch||(a=b.getPCevts(a)),c.unbind(f,a,d)})});if(3===e.length&&"string"===b.getType(e[2])){var g=e[2];return void f.forEach(function(d){a=e[1].split(" "),a.forEach(function(a){b.hasTouch||(a=b.getPCevts(a)),c.undelegate(d,a,g)})})}return 4===e.length?(d=e[3],void f.forEach(function(f){a=e[1].split(" "),a.forEach(function(a){b.hasTouch||(a=b.getPCevts(a)),c.undelegate(f,a,g,d)})})):void 0},D=function(a,d,e){var f=arguments;b.hasTouch||(d=b.getPCevts(d));var g="string"===b.getType(f[0])?document.querySelectorAll(f[0]):f[0];g=g.length?Array.prototype.call(g):[g],g.forEach(function(a){c.trigger(a,d,e)})};a();var E={};return E.on=E.bind=E.live=B,E.off=E.unbind=E.die=C,E.config=d,E.trigger=D,E}); -------------------------------------------------------------------------------- /myvue/src/js/vue-router.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * vue-router v2.2.0 3 | * (c) 2017 Evan You 4 | * @license MIT 5 | */ 6 | !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueRouter=e()}(this,function(){"use strict";function t(t,e){t||"undefined"!=typeof console&&console.warn("[vue-router] "+e)}function e(e,n){switch(typeof n){case"undefined":return;case"object":return n;case"function":return n(e);case"boolean":return n?e.params:void 0;default:t(!1,'props in "'+e.path+'" is a '+typeof n+", expecting an object, function or boolean.")}}function n(t,e){if(void 0===e&&(e={}),t){var n;try{n=r(t)}catch(t){n={}}for(var o in e)n[o]=e[o];return n}return e}function r(t){var e={};return(t=t.trim().replace(/^(\?|#|&)/,""))?(t.split("&").forEach(function(t){var n=t.replace(/\+/g," ").split("="),r=_t(n.shift()),o=n.length>0?_t(n.join("=")):null;void 0===e[r]?e[r]=o:Array.isArray(e[r])?e[r].push(o):e[r]=[e[r],o]}),e):e}function o(t){var e=t?Object.keys(t).map(function(e){var n=t[e];if(void 0===n)return"";if(null===n)return Ct(e);if(Array.isArray(n)){var r=[];return n.slice().forEach(function(t){void 0!==t&&(null===t?r.push(Ct(e)):r.push(Ct(e)+"="+Ct(t)))}),r.join("&")}return Ct(e)+"="+Ct(n)}).filter(function(t){return t.length>0}).join("&"):null;return e?"?"+e:""}function i(t,e,n){var r={name:e.name||t&&t.name,meta:t&&t.meta||{},path:e.path||"/",hash:e.hash||"",query:e.query||{},params:e.params||{},fullPath:u(e),matched:t?a(t):[]};return n&&(r.redirectedFrom=u(n)),Object.freeze(r)}function a(t){for(var e=[];t;)e.unshift(t),t=t.parent;return e}function u(t){var e=t.path,n=t.query;void 0===n&&(n={});var r=t.hash;return void 0===r&&(r=""),(e||"/")+o(n)+r}function c(t,e){return e===$t?t===e:!!e&&(t.path&&e.path?t.path.replace(Tt,"")===e.path.replace(Tt,"")&&t.hash===e.hash&&s(t.query,e.query):!(!t.name||!e.name)&&(t.name===e.name&&t.hash===e.hash&&s(t.query,e.query)&&s(t.params,e.params)))}function s(t,e){void 0===t&&(t={}),void 0===e&&(e={});var n=Object.keys(t),r=Object.keys(e);return n.length===r.length&&n.every(function(n){return String(t[n])===String(e[n])})}function p(t,e){return 0===t.path.replace(Tt,"/").indexOf(e.path.replace(Tt,"/"))&&(!e.hash||t.hash===e.hash)&&f(t.query,e.query)}function f(t,e){for(var n in e)if(!(n in t))return!1;return!0}function h(t){if(!(t.metaKey||t.ctrlKey||t.shiftKey||t.defaultPrevented||void 0!==t.button&&0!==t.button)){if(t.target&&t.target.getAttribute){var e=t.target.getAttribute("target");if(/\b_blank\b/i.test(e))return}return t.preventDefault&&t.preventDefault(),!0}}function l(t){if(t)for(var e,n=0;n=0&&(e=t.slice(r),t=t.slice(0,r));var o=t.indexOf("?");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{path:t,query:n,hash:e}}function m(t){return t.replace(/\/\//g,"/")}function g(t,e,n){var r=e||Object.create(null),o=n||Object.create(null);return t.forEach(function(t){w(r,o,t)}),{pathMap:r,nameMap:o}}function w(t,e,n,r,o){var i=n.path,a=n.name,u={path:b(i,r),components:n.components||{default:n.component},instances:{},name:a,parent:r,matchAs:o,redirect:n.redirect,beforeEnter:n.beforeEnter,meta:n.meta||{},props:null==n.props?{}:n.components?n.props:{default:n.props}};if(n.children&&n.children.forEach(function(n){var r=o?m(o+"/"+n.path):void 0;w(t,e,n,u,r)}),void 0!==n.alias)if(Array.isArray(n.alias))n.alias.forEach(function(o){var i={path:o,children:n.children};w(t,e,i,r,u.path)});else{var c={path:n.alias,children:n.children};w(t,e,c,r,u.path)}t[u.path]||(t[u.path]=u),a&&(e[a]||(e[a]=u))}function b(t,e){return t=t.replace(/\/$/,""),"/"===t[0]?t:null==e?t:m(e.path+"/"+t)}function x(t,e){for(var n,r=[],o=0,i=0,a="",u=e&&e.delimiter||"/";null!=(n=Ft.exec(t));){var c=n[0],s=n[1],p=n.index;if(a+=t.slice(i,p),i=p+c.length,s)a+=s[1];else{var f=t[i],h=n[2],l=n[3],d=n[4],y=n[5],v=n[6],m=n[7];a&&(r.push(a),a="");var g=null!=h&&null!=f&&f!==h,w="+"===v||"*"===v,b="?"===v||"*"===v,x=n[2]||u,k=d||y;r.push({name:l||o++,prefix:h||"",delimiter:x,optional:b,repeat:w,partial:g,asterisk:!!m,pattern:k?A(k):m?".*":"[^"+j(x)+"]+?"})}}return i-1&&(r.params[c]=e.params[c]);if(i)return r.path=U(i.path,r.params,'named route "'+o+'"'),u(i,r,n)}else if(r.path){r.params={};for(var f in s)if(B(f,r.params,r.path))return u(s[f],r,n)}return u(null,r)}function o(e,n){var o=e.redirect,a="function"==typeof o?o(i(e,n)):o;if("string"==typeof a&&(a={path:a}),!a||"object"!=typeof a)return u(null,n);var c=a,s=c.name,f=c.path,h=n.query,l=n.hash,d=n.params;if(h=c.hasOwnProperty("query")?c.query:h,l=c.hasOwnProperty("hash")?c.hash:l,d=c.hasOwnProperty("params")?c.params:d,s){p[s];return r({_normalized:!0,name:s,query:h,hash:l,params:d},void 0,n)}if(f){var y=H(f,e),v=U(y,d,'redirect route with path "'+y+'"');return r({_normalized:!0,path:v,query:h,hash:l},void 0,n)}return t(!1,"invalid redirect option: "+JSON.stringify(a)),u(null,n)}function a(t,e,n){var o=U(n,e.params,'aliased route with path "'+n+'"'),i=r({_normalized:!0,path:o});if(i){var a=i.matched,c=a[a.length-1];return e.params=i.params,u(c,e)}return u(null,e)}function u(t,e,n){return t&&t.redirect?o(t,n||e):t&&t.matchAs?a(t,e,t.matchAs):i(t,e,n)}var c=g(e),s=c.pathMap,p=c.nameMap;return{match:r,addRoutes:n}}function B(t,e,n){var r=P(t),o=r.regexp,i=r.keys,a=n.match(o);if(!a)return!1;if(!e)return!0;for(var u=1,c=a.length;u=t.length?n():t[o]?e(t[o],function(){r(o+1)}):r(o+1)};r(0)}function nt(t){if(!t)if(Pt){var e=document.querySelector("base");t=e?e.getAttribute("href"):"/"}else t="/";return"/"!==t.charAt(0)&&(t="/"+t),t.replace(/\/$/,"")}function rt(t,e){var n,r=Math.max(t.length,e.length);for(n=0;n=0?e:0)+"#"+t)}function kt(t,e,n){var r="hash"===n?"#"+e:e;return t?m(t+"/"+r):r}var Ot,Rt={name:"router-view",functional:!0,props:{name:{type:String,default:"default"}},render:function(t,n){var r=n.props,o=n.children,i=n.parent,a=n.data;a.routerView=!0;for(var u=r.name,c=i.$route,s=i._routerViewCache||(i._routerViewCache={}),p=0,f=!1;i;)i.$vnode&&i.$vnode.data.routerView&&p++,i._inactive&&(f=!0),i=i.$parent;if(a.routerViewDepth=p,f)return t(s[u],a,o);var h=c.matched[p];if(!h)return s[u]=null,t();var l=s[u]=h.components[u],d=a.hook||(a.hook={});return d.init=function(t){h.instances[u]=t.child},d.prepatch=function(t,e){h.instances[u]=e.child},d.destroy=function(t){h.instances[u]===t.child&&(h.instances[u]=void 0)},a.props=e(c,h.props&&h.props[u]),t(l,a,o)}},Et=/[!'()*]/g,jt=function(t){return"%"+t.charCodeAt(0).toString(16)},At=/%2C/g,Ct=function(t){return encodeURIComponent(t).replace(Et,jt).replace(At,",")},_t=decodeURIComponent,Tt=/\/?$/,$t=i(null,{path:"/"}),St=[String,Object],qt=[String,Array],Lt={name:"router-link",props:{to:{type:St,required:!0},tag:{type:String,default:"a"},exact:Boolean,append:Boolean,replace:Boolean,activeClass:String,event:{type:qt,default:"click"}},render:function(t){var e=this,n=this.$router,r=this.$route,o=n.resolve(this.to,r,this.append),a=o.location,u=o.route,s=o.href,f={},d=this.activeClass||n.options.linkActiveClass||"router-link-active",y=a.path?i(null,a):u;f[d]=this.exact?c(r,y):p(r,y);var v=function(t){h(t)&&(e.replace?n.replace(a):n.push(a))},m={click:h};Array.isArray(this.event)?this.event.forEach(function(t){m[t]=v}):m[this.event]=v;var g={class:f};if("a"===this.tag)g.on=m,g.attrs={href:s};else{var w=l(this.$slots.default);if(w){w.isStatic=!1;var b=Ot.util.extend,x=w.data=b({},w.data);x.on=m;var k=w.data.attrs=b({},w.data.attrs);k.href=s}else g.on=m}return t(this.tag,g,this.$slots.default)}},Pt="undefined"!=typeof window,Ut=Array.isArray||function(t){return"[object Array]"==Object.prototype.toString.call(t)},zt=Ut,Mt=L,Vt=x,Bt=k,Ht=E,It=q,Ft=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g");Mt.parse=Vt,Mt.compile=Bt,Mt.tokensToFunction=Ht,Mt.tokensToRegExp=It;var Dt=Object.create(null),Jt=Object.create(null),Kt=Object.create(null),Nt=Pt&&function(){var t=window.navigator.userAgent;return(t.indexOf("Android 2.")===-1&&t.indexOf("Android 4.0")===-1||t.indexOf("Mobile Safari")===-1||t.indexOf("Chrome")!==-1||t.indexOf("Windows Phone")!==-1)&&(window.history&&"pushState"in window.history)}(),Xt=Pt&&window.performance&&window.performance.now?window.performance:Date,Yt=W(),Wt=function(t,e){this.router=t,this.base=nt(e),this.current=$t,this.pending=null,this.ready=!1,this.readyCbs=[]};Wt.prototype.listen=function(t){this.cb=t},Wt.prototype.onReady=function(t){this.ready?t():this.readyCbs.push(t)},Wt.prototype.transitionTo=function(t,e,n){var r=this,o=this.router.match(t,this.current);this.confirmTransition(o,function(){r.updateRoute(o),e&&e(o),r.ensureURL(),r.ready||(r.ready=!0,r.readyCbs.forEach(function(t){t(o)}))},n)},Wt.prototype.confirmTransition=function(t,e,n){var r=this,o=this.current,i=function(){n&&n()};if(c(t,o)&&t.matched.length===o.matched.length)return this.ensureURL(),i();var a=rt(this.current.matched,t.matched),u=a.updated,s=a.deactivated,p=a.activated,f=[].concat(at(s),this.router.beforeHooks,ut(u),p.map(function(t){return t.beforeEnter}),ht(p));this.pending=t;var h=function(e,n){return r.pending!==t?i():void e(t,o,function(t){t===!1?(r.ensureURL(!0),i()):"string"==typeof t||"object"==typeof t?("object"==typeof t&&t.replace?r.replace(t):r.push(t),i()):n(t)})};et(f,h,function(){var n=[],o=function(){return r.current===t},a=st(p,n,o);et(a,h,function(){return r.pending!==t?i():(r.pending=null,e(t),void(r.router.app&&r.router.app.$nextTick(function(){n.forEach(function(t){return t()})})))})})},Wt.prototype.updateRoute=function(t){var e=this.current;this.current=t,this.cb&&this.cb(t),this.router.afterHooks.forEach(function(n){n&&n(t,e)})};var Gt=function(t){function e(e,n){var r=this;t.call(this,e,n);var o=e.options.scrollBehavior;o&&I(),window.addEventListener("popstate",function(t){r.transitionTo(vt(r.base),function(t){o&&F(e,t,r.current,!0)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.go=function(t){window.history.go(t)},e.prototype.push=function(t,e,n){var r=this;this.transitionTo(t,function(t){Z(m(r.base+t.fullPath)),F(r.router,t,r.current,!1),e&&e(t)},n)},e.prototype.replace=function(t,e,n){var r=this;this.transitionTo(t,function(t){tt(m(r.base+t.fullPath)),F(r.router,t,r.current,!1),e&&e(t)},n)},e.prototype.ensureURL=function(t){if(vt(this.base)!==this.current.fullPath){var e=m(this.base+this.current.fullPath);t?Z(e):tt(e)}},e.prototype.getCurrentLocation=function(){return vt(this.base)},e}(Wt),Qt=function(t){function e(e,n,r){t.call(this,e,n),r&&mt(this.base)||gt()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setupListeners=function(){var t=this;window.addEventListener("hashchange",function(){gt()&&t.transitionTo(wt(),function(t){xt(t.fullPath)})})},e.prototype.push=function(t,e,n){this.transitionTo(t,function(t){bt(t.fullPath),e&&e(t)},n)},e.prototype.replace=function(t,e,n){this.transitionTo(t,function(t){xt(t.fullPath),e&&e(t)},n)},e.prototype.go=function(t){window.history.go(t)},e.prototype.ensureURL=function(t){var e=this.current.fullPath;wt()!==e&&(t?bt(e):xt(e))},e.prototype.getCurrentLocation=function(){return wt()},e}(Wt),Zt=function(t){function e(e,n){t.call(this,e,n),this.stack=[],this.index=-1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.push=function(t,e,n){var r=this;this.transitionTo(t,function(t){r.stack=r.stack.slice(0,r.index+1).concat(t),r.index++,e&&e(t)},n)},e.prototype.replace=function(t,e,n){var r=this;this.transitionTo(t,function(t){r.stack=r.stack.slice(0,r.index).concat(t),e&&e(t)},n)},e.prototype.go=function(t){var e=this,n=this.index+t;if(!(n<0||n>=this.stack.length)){var r=this.stack[n];this.confirmTransition(r,function(){e.index=n,e.updateRoute(r)})}},e.prototype.getCurrentLocation=function(){var t=this.stack[this.stack.length-1];return t?t.fullPath:"/"},e.prototype.ensureURL=function(){},e}(Wt),te=function(t){void 0===t&&(t={}),this.app=null,this.apps=[],this.options=t,this.beforeHooks=[],this.afterHooks=[],this.matcher=V(t.routes||[]);var e=t.mode||"hash";switch(this.fallback="history"===e&&!Nt,this.fallback&&(e="hash"),Pt||(e="abstract"),this.mode=e,e){case"history":this.history=new Gt(this,t.base);break;case"hash":this.history=new Qt(this,t.base,this.fallback);break;case"abstract":this.history=new Zt(this,t.base)}},ee={currentRoute:{}};return te.prototype.match=function(t,e,n){return this.matcher.match(t,e,n)},ee.currentRoute.get=function(){return this.history&&this.history.current},te.prototype.init=function(t){var e=this;if(this.apps.push(t),!this.app){this.app=t;var n=this.history;if(n instanceof Gt)n.transitionTo(n.getCurrentLocation());else if(n instanceof Qt){var r=function(){n.setupListeners()};n.transitionTo(n.getCurrentLocation(),r,r)}n.listen(function(t){e.apps.forEach(function(e){e._route=t})})}},te.prototype.beforeEach=function(t){this.beforeHooks.push(t)},te.prototype.afterEach=function(t){this.afterHooks.push(t)},te.prototype.onReady=function(t){this.history.onReady(t)},te.prototype.push=function(t,e,n){this.history.push(t,e,n)},te.prototype.replace=function(t,e,n){this.history.replace(t,e,n)},te.prototype.go=function(t){this.history.go(t)},te.prototype.back=function(){this.go(-1)},te.prototype.forward=function(){this.go(1)},te.prototype.getMatchedComponents=function(t){var e=t?this.resolve(t).route:this.currentRoute;return e?[].concat.apply([],e.matched.map(function(t){return Object.keys(t.components).map(function(e){return t.components[e]})})):[]},te.prototype.resolve=function(t,e,n){var r=z(t,e||this.history.current,n),o=this.match(r,e),i=o.redirectedFrom||o.fullPath,a=this.history.base,u=kt(a,i,this.mode);return{location:r,route:o,href:u,normalizedTo:r,resolved:o}},te.prototype.addRoutes=function(t){this.matcher.addRoutes(t),this.history.current!==$t&&this.history.transitionTo(this.history.getCurrentLocation())},Object.defineProperties(te.prototype,ee),te.install=d,te.version="2.2.0",Pt&&window.Vue&&window.Vue.use(te),te}); -------------------------------------------------------------------------------- /myvue/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | login 113 | 114 | 115 | loginimg 116 | 117 | 118 | 119 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | true 139 | DEFINITION_ORDER 140 | 141 | 142 | 143 | 144 | 145 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 173 | 174 | 177 | 178 | 179 | 180 | 183 | 184 | 187 | 188 | 191 | 192 | 193 | 194 | 197 | 198 | 201 | 202 | 205 | 206 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 240 | 241 | 242 | 243 | 1494749196632 244 | 249 | 250 | 251 | 252 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 280 | 281 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | -------------------------------------------------------------------------------- /myvue/src/js/zepto-1.1.6.min.js: -------------------------------------------------------------------------------- 1 | /* Zepto v1.1.6 - zepto event ajax form ie - zeptojs.com/license */ 2 | var Zepto=function(){function L(t){return null==t?String(t):j[S.call(t)]||"object"}function Z(t){return"function"==L(t)}function _(t){return null!=t&&t==t.window}function $(t){return null!=t&&t.nodeType==t.DOCUMENT_NODE}function D(t){return"object"==L(t)}function M(t){return D(t)&&!_(t)&&Object.getPrototypeOf(t)==Object.prototype}function R(t){return"number"==typeof t.length}function k(t){return s.call(t,function(t){return null!=t})}function z(t){return t.length>0?n.fn.concat.apply([],t):t}function F(t){return t.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function q(t){return t in f?f[t]:f[t]=new RegExp("(^|\\s)"+t+"(\\s|$)")}function H(t,e){return"number"!=typeof e||c[F(t)]?e:e+"px"}function I(t){var e,n;return u[t]||(e=a.createElement(t),a.body.appendChild(e),n=getComputedStyle(e,"").getPropertyValue("display"),e.parentNode.removeChild(e),"none"==n&&(n="block"),u[t]=n),u[t]}function V(t){return"children"in t?o.call(t.children):n.map(t.childNodes,function(t){return 1==t.nodeType?t:void 0})}function B(n,i,r){for(e in i)r&&(M(i[e])||A(i[e]))?(M(i[e])&&!M(n[e])&&(n[e]={}),A(i[e])&&!A(n[e])&&(n[e]=[]),B(n[e],i[e],r)):i[e]!==t&&(n[e]=i[e])}function U(t,e){return null==e?n(t):n(t).filter(e)}function J(t,e,n,i){return Z(e)?e.call(t,n,i):e}function X(t,e,n){null==n?t.removeAttribute(e):t.setAttribute(e,n)}function W(e,n){var i=e.className||"",r=i&&i.baseVal!==t;return n===t?r?i.baseVal:i:void(r?i.baseVal=n:e.className=n)}function Y(t){try{return t?"true"==t||("false"==t?!1:"null"==t?null:+t+""==t?+t:/^[\[\{]/.test(t)?n.parseJSON(t):t):t}catch(e){return t}}function G(t,e){e(t);for(var n=0,i=t.childNodes.length;i>n;n++)G(t.childNodes[n],e)}var t,e,n,i,C,N,r=[],o=r.slice,s=r.filter,a=window.document,u={},f={},c={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},l=/^\s*<(\w+|!)[^>]*>/,h=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,p=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,d=/^(?:body|html)$/i,m=/([A-Z])/g,g=["val","css","html","text","data","width","height","offset"],v=["after","prepend","before","append"],y=a.createElement("table"),x=a.createElement("tr"),b={tr:a.createElement("tbody"),tbody:y,thead:y,tfoot:y,td:x,th:x,"*":a.createElement("div")},w=/complete|loaded|interactive/,E=/^[\w-]*$/,j={},S=j.toString,T={},O=a.createElement("div"),P={tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},A=Array.isArray||function(t){return t instanceof Array};return T.matches=function(t,e){if(!e||!t||1!==t.nodeType)return!1;var n=t.webkitMatchesSelector||t.mozMatchesSelector||t.oMatchesSelector||t.matchesSelector;if(n)return n.call(t,e);var i,r=t.parentNode,o=!r;return o&&(r=O).appendChild(t),i=~T.qsa(r,e).indexOf(t),o&&O.removeChild(t),i},C=function(t){return t.replace(/-+(.)?/g,function(t,e){return e?e.toUpperCase():""})},N=function(t){return s.call(t,function(e,n){return t.indexOf(e)==n})},T.fragment=function(e,i,r){var s,u,f;return h.test(e)&&(s=n(a.createElement(RegExp.$1))),s||(e.replace&&(e=e.replace(p,"<$1>")),i===t&&(i=l.test(e)&&RegExp.$1),i in b||(i="*"),f=b[i],f.innerHTML=""+e,s=n.each(o.call(f.childNodes),function(){f.removeChild(this)})),M(r)&&(u=n(s),n.each(r,function(t,e){g.indexOf(t)>-1?u[t](e):u.attr(t,e)})),s},T.Z=function(t,e){return t=t||[],t.__proto__=n.fn,t.selector=e||"",t},T.isZ=function(t){return t instanceof T.Z},T.init=function(e,i){var r;if(!e)return T.Z();if("string"==typeof e)if(e=e.trim(),"<"==e[0]&&l.test(e))r=T.fragment(e,RegExp.$1,i),e=null;else{if(i!==t)return n(i).find(e);r=T.qsa(a,e)}else{if(Z(e))return n(a).ready(e);if(T.isZ(e))return e;if(A(e))r=k(e);else if(D(e))r=[e],e=null;else if(l.test(e))r=T.fragment(e.trim(),RegExp.$1,i),e=null;else{if(i!==t)return n(i).find(e);r=T.qsa(a,e)}}return T.Z(r,e)},n=function(t,e){return T.init(t,e)},n.extend=function(t){var e,n=o.call(arguments,1);return"boolean"==typeof t&&(e=t,t=n.shift()),n.forEach(function(n){B(t,n,e)}),t},T.qsa=function(t,e){var n,i="#"==e[0],r=!i&&"."==e[0],s=i||r?e.slice(1):e,a=E.test(s);return $(t)&&a&&i?(n=t.getElementById(s))?[n]:[]:1!==t.nodeType&&9!==t.nodeType?[]:o.call(a&&!i?r?t.getElementsByClassName(s):t.getElementsByTagName(e):t.querySelectorAll(e))},n.contains=a.documentElement.contains?function(t,e){return t!==e&&t.contains(e)}:function(t,e){for(;e&&(e=e.parentNode);)if(e===t)return!0;return!1},n.type=L,n.isFunction=Z,n.isWindow=_,n.isArray=A,n.isPlainObject=M,n.isEmptyObject=function(t){var e;for(e in t)return!1;return!0},n.inArray=function(t,e,n){return r.indexOf.call(e,t,n)},n.camelCase=C,n.trim=function(t){return null==t?"":String.prototype.trim.call(t)},n.uuid=0,n.support={},n.expr={},n.map=function(t,e){var n,r,o,i=[];if(R(t))for(r=0;r=0?e:e+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each(function(){null!=this.parentNode&&this.parentNode.removeChild(this)})},each:function(t){return r.every.call(this,function(e,n){return t.call(e,n,e)!==!1}),this},filter:function(t){return Z(t)?this.not(this.not(t)):n(s.call(this,function(e){return T.matches(e,t)}))},add:function(t,e){return n(N(this.concat(n(t,e))))},is:function(t){return this.length>0&&T.matches(this[0],t)},not:function(e){var i=[];if(Z(e)&&e.call!==t)this.each(function(t){e.call(this,t)||i.push(this)});else{var r="string"==typeof e?this.filter(e):R(e)&&Z(e.item)?o.call(e):n(e);this.forEach(function(t){r.indexOf(t)<0&&i.push(t)})}return n(i)},has:function(t){return this.filter(function(){return D(t)?n.contains(this,t):n(this).find(t).size()})},eq:function(t){return-1===t?this.slice(t):this.slice(t,+t+1)},first:function(){var t=this[0];return t&&!D(t)?t:n(t)},last:function(){var t=this[this.length-1];return t&&!D(t)?t:n(t)},find:function(t){var e,i=this;return e=t?"object"==typeof t?n(t).filter(function(){var t=this;return r.some.call(i,function(e){return n.contains(e,t)})}):1==this.length?n(T.qsa(this[0],t)):this.map(function(){return T.qsa(this,t)}):n()},closest:function(t,e){var i=this[0],r=!1;for("object"==typeof t&&(r=n(t));i&&!(r?r.indexOf(i)>=0:T.matches(i,t));)i=i!==e&&!$(i)&&i.parentNode;return n(i)},parents:function(t){for(var e=[],i=this;i.length>0;)i=n.map(i,function(t){return(t=t.parentNode)&&!$(t)&&e.indexOf(t)<0?(e.push(t),t):void 0});return U(e,t)},parent:function(t){return U(N(this.pluck("parentNode")),t)},children:function(t){return U(this.map(function(){return V(this)}),t)},contents:function(){return this.map(function(){return o.call(this.childNodes)})},siblings:function(t){return U(this.map(function(t,e){return s.call(V(e.parentNode),function(t){return t!==e})}),t)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(t){return n.map(this,function(e){return e[t]})},show:function(){return this.each(function(){"none"==this.style.display&&(this.style.display=""),"none"==getComputedStyle(this,"").getPropertyValue("display")&&(this.style.display=I(this.nodeName))})},replaceWith:function(t){return this.before(t).remove()},wrap:function(t){var e=Z(t);if(this[0]&&!e)var i=n(t).get(0),r=i.parentNode||this.length>1;return this.each(function(o){n(this).wrapAll(e?t.call(this,o):r?i.cloneNode(!0):i)})},wrapAll:function(t){if(this[0]){n(this[0]).before(t=n(t));for(var e;(e=t.children()).length;)t=e.first();n(t).append(this)}return this},wrapInner:function(t){var e=Z(t);return this.each(function(i){var r=n(this),o=r.contents(),s=e?t.call(this,i):t;o.length?o.wrapAll(s):r.append(s)})},unwrap:function(){return this.parent().each(function(){n(this).replaceWith(n(this).children())}),this},clone:function(){return this.map(function(){return this.cloneNode(!0)})},hide:function(){return this.css("display","none")},toggle:function(e){return this.each(function(){var i=n(this);(e===t?"none"==i.css("display"):e)?i.show():i.hide()})},prev:function(t){return n(this.pluck("previousElementSibling")).filter(t||"*")},next:function(t){return n(this.pluck("nextElementSibling")).filter(t||"*")},html:function(t){return 0 in arguments?this.each(function(e){var i=this.innerHTML;n(this).empty().append(J(this,t,e,i))}):0 in this?this[0].innerHTML:null},text:function(t){return 0 in arguments?this.each(function(e){var n=J(this,t,e,this.textContent);this.textContent=null==n?"":""+n}):0 in this?this[0].textContent:null},attr:function(n,i){var r;return"string"!=typeof n||1 in arguments?this.each(function(t){if(1===this.nodeType)if(D(n))for(e in n)X(this,e,n[e]);else X(this,n,J(this,i,t,this.getAttribute(n)))}):this.length&&1===this[0].nodeType?!(r=this[0].getAttribute(n))&&n in this[0]?this[0][n]:r:t},removeAttr:function(t){return this.each(function(){1===this.nodeType&&t.split(" ").forEach(function(t){X(this,t)},this)})},prop:function(t,e){return t=P[t]||t,1 in arguments?this.each(function(n){this[t]=J(this,e,n,this[t])}):this[0]&&this[0][t]},data:function(e,n){var i="data-"+e.replace(m,"-$1").toLowerCase(),r=1 in arguments?this.attr(i,n):this.attr(i);return null!==r?Y(r):t},val:function(t){return 0 in arguments?this.each(function(e){this.value=J(this,t,e,this.value)}):this[0]&&(this[0].multiple?n(this[0]).find("option").filter(function(){return this.selected}).pluck("value"):this[0].value)},offset:function(t){if(t)return this.each(function(e){var i=n(this),r=J(this,t,e,i.offset()),o=i.offsetParent().offset(),s={top:r.top-o.top,left:r.left-o.left};"static"==i.css("position")&&(s.position="relative"),i.css(s)});if(!this.length)return null;var e=this[0].getBoundingClientRect();return{left:e.left+window.pageXOffset,top:e.top+window.pageYOffset,width:Math.round(e.width),height:Math.round(e.height)}},css:function(t,i){if(arguments.length<2){var r,o=this[0];if(!o)return;if(r=getComputedStyle(o,""),"string"==typeof t)return o.style[C(t)]||r.getPropertyValue(t);if(A(t)){var s={};return n.each(t,function(t,e){s[e]=o.style[C(e)]||r.getPropertyValue(e)}),s}}var a="";if("string"==L(t))i||0===i?a=F(t)+":"+H(t,i):this.each(function(){this.style.removeProperty(F(t))});else for(e in t)t[e]||0===t[e]?a+=F(e)+":"+H(e,t[e])+";":this.each(function(){this.style.removeProperty(F(e))});return this.each(function(){this.style.cssText+=";"+a})},index:function(t){return t?this.indexOf(n(t)[0]):this.parent().children().indexOf(this[0])},hasClass:function(t){return t?r.some.call(this,function(t){return this.test(W(t))},q(t)):!1},addClass:function(t){return t?this.each(function(e){if("className"in this){i=[];var r=W(this),o=J(this,t,e,r);o.split(/\s+/g).forEach(function(t){n(this).hasClass(t)||i.push(t)},this),i.length&&W(this,r+(r?" ":"")+i.join(" "))}}):this},removeClass:function(e){return this.each(function(n){if("className"in this){if(e===t)return W(this,"");i=W(this),J(this,e,n,i).split(/\s+/g).forEach(function(t){i=i.replace(q(t)," ")}),W(this,i.trim())}})},toggleClass:function(e,i){return e?this.each(function(r){var o=n(this),s=J(this,e,r,W(this));s.split(/\s+/g).forEach(function(e){(i===t?!o.hasClass(e):i)?o.addClass(e):o.removeClass(e)})}):this},scrollTop:function(e){if(this.length){var n="scrollTop"in this[0];return e===t?n?this[0].scrollTop:this[0].pageYOffset:this.each(n?function(){this.scrollTop=e}:function(){this.scrollTo(this.scrollX,e)})}},scrollLeft:function(e){if(this.length){var n="scrollLeft"in this[0];return e===t?n?this[0].scrollLeft:this[0].pageXOffset:this.each(n?function(){this.scrollLeft=e}:function(){this.scrollTo(e,this.scrollY)})}},position:function(){if(this.length){var t=this[0],e=this.offsetParent(),i=this.offset(),r=d.test(e[0].nodeName)?{top:0,left:0}:e.offset();return i.top-=parseFloat(n(t).css("margin-top"))||0,i.left-=parseFloat(n(t).css("margin-left"))||0,r.top+=parseFloat(n(e[0]).css("border-top-width"))||0,r.left+=parseFloat(n(e[0]).css("border-left-width"))||0,{top:i.top-r.top,left:i.left-r.left}}},offsetParent:function(){return this.map(function(){for(var t=this.offsetParent||a.body;t&&!d.test(t.nodeName)&&"static"==n(t).css("position");)t=t.offsetParent;return t})}},n.fn.detach=n.fn.remove,["width","height"].forEach(function(e){var i=e.replace(/./,function(t){return t[0].toUpperCase()});n.fn[e]=function(r){var o,s=this[0];return r===t?_(s)?s["inner"+i]:$(s)?s.documentElement["scroll"+i]:(o=this.offset())&&o[e]:this.each(function(t){s=n(this),s.css(e,J(this,r,t,s[e]()))})}}),v.forEach(function(t,e){var i=e%2;n.fn[t]=function(){var t,o,r=n.map(arguments,function(e){return t=L(e),"object"==t||"array"==t||null==e?e:T.fragment(e)}),s=this.length>1;return r.length<1?this:this.each(function(t,u){o=i?u:u.parentNode,u=0==e?u.nextSibling:1==e?u.firstChild:2==e?u:null;var f=n.contains(a.documentElement,o);r.forEach(function(t){if(s)t=t.cloneNode(!0);else if(!o)return n(t).remove();o.insertBefore(t,u),f&&G(t,function(t){null==t.nodeName||"SCRIPT"!==t.nodeName.toUpperCase()||t.type&&"text/javascript"!==t.type||t.src||window.eval.call(window,t.innerHTML)})})})},n.fn[i?t+"To":"insert"+(e?"Before":"After")]=function(e){return n(e)[t](this),this}}),T.Z.prototype=n.fn,T.uniq=N,T.deserializeValue=Y,n.zepto=T,n}();window.Zepto=Zepto,void 0===window.$&&(window.$=Zepto),function(t){function l(t){return t._zid||(t._zid=e++)}function h(t,e,n,i){if(e=p(e),e.ns)var r=d(e.ns);return(s[l(t)]||[]).filter(function(t){return!(!t||e.e&&t.e!=e.e||e.ns&&!r.test(t.ns)||n&&l(t.fn)!==l(n)||i&&t.sel!=i)})}function p(t){var e=(""+t).split(".");return{e:e[0],ns:e.slice(1).sort().join(" ")}}function d(t){return new RegExp("(?:^| )"+t.replace(" "," .* ?")+"(?: |$)")}function m(t,e){return t.del&&!u&&t.e in f||!!e}function g(t){return c[t]||u&&f[t]||t}function v(e,i,r,o,a,u,f){var h=l(e),d=s[h]||(s[h]=[]);i.split(/\s/).forEach(function(i){if("ready"==i)return t(document).ready(r);var s=p(i);s.fn=r,s.sel=a,s.e in c&&(r=function(e){var n=e.relatedTarget;return!n||n!==this&&!t.contains(this,n)?s.fn.apply(this,arguments):void 0}),s.del=u;var l=u||r;s.proxy=function(t){if(t=j(t),!t.isImmediatePropagationStopped()){t.data=o;var i=l.apply(e,t._args==n?[t]:[t].concat(t._args));return i===!1&&(t.preventDefault(),t.stopPropagation()),i}},s.i=d.length,d.push(s),"addEventListener"in e&&e.addEventListener(g(s.e),s.proxy,m(s,f))})}function y(t,e,n,i,r){var o=l(t);(e||"").split(/\s/).forEach(function(e){h(t,e,n,i).forEach(function(e){delete s[o][e.i],"removeEventListener"in t&&t.removeEventListener(g(e.e),e.proxy,m(e,r))})})}function j(e,i){return(i||!e.isDefaultPrevented)&&(i||(i=e),t.each(E,function(t,n){var r=i[t];e[t]=function(){return this[n]=x,r&&r.apply(i,arguments)},e[n]=b}),(i.defaultPrevented!==n?i.defaultPrevented:"returnValue"in i?i.returnValue===!1:i.getPreventDefault&&i.getPreventDefault())&&(e.isDefaultPrevented=x)),e}function S(t){var e,i={originalEvent:t};for(e in t)w.test(e)||t[e]===n||(i[e]=t[e]);return j(i,t)}var n,e=1,i=Array.prototype.slice,r=t.isFunction,o=function(t){return"string"==typeof t},s={},a={},u="onfocusin"in window,f={focus:"focusin",blur:"focusout"},c={mouseenter:"mouseover",mouseleave:"mouseout"};a.click=a.mousedown=a.mouseup=a.mousemove="MouseEvents",t.event={add:v,remove:y},t.proxy=function(e,n){var s=2 in arguments&&i.call(arguments,2);if(r(e)){var a=function(){return e.apply(n,s?s.concat(i.call(arguments)):arguments)};return a._zid=l(e),a}if(o(n))return s?(s.unshift(e[n],e),t.proxy.apply(null,s)):t.proxy(e[n],e);throw new TypeError("expected function")},t.fn.bind=function(t,e,n){return this.on(t,e,n)},t.fn.unbind=function(t,e){return this.off(t,e)},t.fn.one=function(t,e,n,i){return this.on(t,e,n,i,1)};var x=function(){return!0},b=function(){return!1},w=/^([A-Z]|returnValue$|layer[XY]$)/,E={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};t.fn.delegate=function(t,e,n){return this.on(e,t,n)},t.fn.undelegate=function(t,e,n){return this.off(e,t,n)},t.fn.live=function(e,n){return t(document.body).delegate(this.selector,e,n),this},t.fn.die=function(e,n){return t(document.body).undelegate(this.selector,e,n),this},t.fn.on=function(e,s,a,u,f){var c,l,h=this;return e&&!o(e)?(t.each(e,function(t,e){h.on(t,s,a,e,f)}),h):(o(s)||r(u)||u===!1||(u=a,a=s,s=n),(r(a)||a===!1)&&(u=a,a=n),u===!1&&(u=b),h.each(function(n,r){f&&(c=function(t){return y(r,t.type,u),u.apply(this,arguments)}),s&&(l=function(e){var n,o=t(e.target).closest(s,r).get(0);return o&&o!==r?(n=t.extend(S(e),{currentTarget:o,liveFired:r}),(c||u).apply(o,[n].concat(i.call(arguments,1)))):void 0}),v(r,e,u,a,s,l||c)}))},t.fn.off=function(e,i,s){var a=this;return e&&!o(e)?(t.each(e,function(t,e){a.off(t,i,e)}),a):(o(i)||r(s)||s===!1||(s=i,i=n),s===!1&&(s=b),a.each(function(){y(this,e,s,i)}))},t.fn.trigger=function(e,n){return e=o(e)||t.isPlainObject(e)?t.Event(e):j(e),e._args=n,this.each(function(){e.type in f&&"function"==typeof this[e.type]?this[e.type]():"dispatchEvent"in this?this.dispatchEvent(e):t(this).triggerHandler(e,n)})},t.fn.triggerHandler=function(e,n){var i,r;return this.each(function(s,a){i=S(o(e)?t.Event(e):e),i._args=n,i.target=a,t.each(h(a,e.type||e),function(t,e){return r=e.proxy(i),i.isImmediatePropagationStopped()?!1:void 0})}),r},"focusin focusout focus blur load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach(function(e){t.fn[e]=function(t){return 0 in arguments?this.bind(e,t):this.trigger(e)}}),t.Event=function(t,e){o(t)||(e=t,t=e.type);var n=document.createEvent(a[t]||"Events"),i=!0;if(e)for(var r in e)"bubbles"==r?i=!!e[r]:n[r]=e[r];return n.initEvent(t,i,!0),j(n)}}(Zepto),function(t){function h(e,n,i){var r=t.Event(n);return t(e).trigger(r,i),!r.isDefaultPrevented()}function p(t,e,i,r){return t.global?h(e||n,i,r):void 0}function d(e){e.global&&0===t.active++&&p(e,null,"ajaxStart")}function m(e){e.global&&!--t.active&&p(e,null,"ajaxStop")}function g(t,e){var n=e.context;return e.beforeSend.call(n,t,e)===!1||p(e,n,"ajaxBeforeSend",[t,e])===!1?!1:void p(e,n,"ajaxSend",[t,e])}function v(t,e,n,i){var r=n.context,o="success";n.success.call(r,t,o,e),i&&i.resolveWith(r,[t,o,e]),p(n,r,"ajaxSuccess",[e,n,t]),x(o,e,n)}function y(t,e,n,i,r){var o=i.context;i.error.call(o,n,e,t),r&&r.rejectWith(o,[n,e,t]),p(i,o,"ajaxError",[n,i,t||e]),x(e,n,i)}function x(t,e,n){var i=n.context;n.complete.call(i,e,t),p(n,i,"ajaxComplete",[e,n]),m(n)}function b(){}function w(t){return t&&(t=t.split(";",2)[0]),t&&(t==f?"html":t==u?"json":s.test(t)?"script":a.test(t)&&"xml")||"text"}function E(t,e){return""==e?t:(t+"&"+e).replace(/[&?]{1,2}/,"?")}function j(e){e.processData&&e.data&&"string"!=t.type(e.data)&&(e.data=t.param(e.data,e.traditional)),!e.data||e.type&&"GET"!=e.type.toUpperCase()||(e.url=E(e.url,e.data),e.data=void 0)}function S(e,n,i,r){return t.isFunction(n)&&(r=i,i=n,n=void 0),t.isFunction(i)||(r=i,i=void 0),{url:e,data:n,success:i,dataType:r}}function C(e,n,i,r){var o,s=t.isArray(n),a=t.isPlainObject(n);t.each(n,function(n,u){o=t.type(u),r&&(n=i?r:r+"["+(a||"object"==o||"array"==o?n:"")+"]"),!r&&s?e.add(u.name,u.value):"array"==o||!i&&"object"==o?C(e,u,i,n):e.add(n,u)})}var i,r,e=0,n=window.document,o=/)<[^<]*)*<\/script>/gi,s=/^(?:text|application)\/javascript/i,a=/^(?:text|application)\/xml/i,u="application/json",f="text/html",c=/^\s*$/,l=n.createElement("a");l.href=window.location.href,t.active=0,t.ajaxJSONP=function(i,r){if(!("type"in i))return t.ajax(i);var f,h,o=i.jsonpCallback,s=(t.isFunction(o)?o():o)||"jsonp"+ ++e,a=n.createElement("script"),u=window[s],c=function(e){t(a).triggerHandler("error",e||"abort")},l={abort:c};return r&&r.promise(l),t(a).on("load error",function(e,n){clearTimeout(h),t(a).off().remove(),"error"!=e.type&&f?v(f[0],l,i,r):y(null,n||"error",l,i,r),window[s]=u,f&&t.isFunction(u)&&u(f[0]),u=f=void 0}),g(l,i)===!1?(c("abort"),l):(window[s]=function(){f=arguments},a.src=i.url.replace(/\?(.+)=\?/,"?$1="+s),n.head.appendChild(a),i.timeout>0&&(h=setTimeout(function(){c("timeout")},i.timeout)),l)},t.ajaxSettings={type:"GET",beforeSend:b,success:b,error:b,complete:b,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript, application/x-javascript",json:u,xml:"application/xml, text/xml",html:f,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0},t.ajax=function(e){var a,o=t.extend({},e||{}),s=t.Deferred&&t.Deferred();for(i in t.ajaxSettings)void 0===o[i]&&(o[i]=t.ajaxSettings[i]);d(o),o.crossDomain||(a=n.createElement("a"),a.href=o.url,a.href=a.href,o.crossDomain=l.protocol+"//"+l.host!=a.protocol+"//"+a.host),o.url||(o.url=window.location.toString()),j(o);var u=o.dataType,f=/\?.+=\?/.test(o.url);if(f&&(u="jsonp"),o.cache!==!1&&(e&&e.cache===!0||"script"!=u&&"jsonp"!=u)||(o.url=E(o.url,"_="+Date.now())),"jsonp"==u)return f||(o.url=E(o.url,o.jsonp?o.jsonp+"=?":o.jsonp===!1?"":"callback=?")),t.ajaxJSONP(o,s);var C,h=o.accepts[u],p={},m=function(t,e){p[t.toLowerCase()]=[t,e]},x=/^([\w-]+:)\/\//.test(o.url)?RegExp.$1:window.location.protocol,S=o.xhr(),T=S.setRequestHeader;if(s&&s.promise(S),o.crossDomain||m("X-Requested-With","XMLHttpRequest"),m("Accept",h||"*/*"),(h=o.mimeType||h)&&(h.indexOf(",")>-1&&(h=h.split(",",2)[0]),S.overrideMimeType&&S.overrideMimeType(h)),(o.contentType||o.contentType!==!1&&o.data&&"GET"!=o.type.toUpperCase())&&m("Content-Type",o.contentType||"application/x-www-form-urlencoded"),o.headers)for(r in o.headers)m(r,o.headers[r]);if(S.setRequestHeader=m,S.onreadystatechange=function(){if(4==S.readyState){S.onreadystatechange=b,clearTimeout(C);var e,n=!1;if(S.status>=200&&S.status<300||304==S.status||0==S.status&&"file:"==x){u=u||w(o.mimeType||S.getResponseHeader("content-type")),e=S.responseText;try{"script"==u?(1,eval)(e):"xml"==u?e=S.responseXML:"json"==u&&(e=c.test(e)?null:t.parseJSON(e))}catch(i){n=i}n?y(n,"parsererror",S,o,s):v(e,S,o,s)}else y(S.statusText||null,S.status?"error":"abort",S,o,s)}},g(S,o)===!1)return S.abort(),y(null,"abort",S,o,s),S;if(o.xhrFields)for(r in o.xhrFields)S[r]=o.xhrFields[r];var N="async"in o?o.async:!0;S.open(o.type,o.url,N,o.username,o.password);for(r in p)T.apply(S,p[r]);return o.timeout>0&&(C=setTimeout(function(){S.onreadystatechange=b,S.abort(),y(null,"timeout",S,o,s)},o.timeout)),S.send(o.data?o.data:null),S},t.get=function(){return t.ajax(S.apply(null,arguments))},t.post=function(){var e=S.apply(null,arguments);return e.type="POST",t.ajax(e)},t.getJSON=function(){var e=S.apply(null,arguments);return e.dataType="json",t.ajax(e)},t.fn.load=function(e,n,i){if(!this.length)return this;var a,r=this,s=e.split(/\s/),u=S(e,n,i),f=u.success;return s.length>1&&(u.url=s[0],a=s[1]),u.success=function(e){r.html(a?t("
").html(e.replace(o,"")).find(a):e),f&&f.apply(r,arguments)},t.ajax(u),this};var T=encodeURIComponent;t.param=function(e,n){var i=[];return i.add=function(e,n){t.isFunction(n)&&(n=n()),null==n&&(n=""),this.push(T(e)+"="+T(n))},C(i,e,n),i.join("&").replace(/%20/g,"+")}}(Zepto),function(t){t.fn.serializeArray=function(){var e,n,i=[],r=function(t){return t.forEach?t.forEach(r):void i.push({name:e,value:t})};return this[0]&&t.each(this[0].elements,function(i,o){n=o.type,e=o.name,e&&"fieldset"!=o.nodeName.toLowerCase()&&!o.disabled&&"submit"!=n&&"reset"!=n&&"button"!=n&&"file"!=n&&("radio"!=n&&"checkbox"!=n||o.checked)&&r(t(o).val())}),i},t.fn.serialize=function(){var t=[];return this.serializeArray().forEach(function(e){t.push(encodeURIComponent(e.name)+"="+encodeURIComponent(e.value))}),t.join("&")},t.fn.submit=function(e){if(0 in arguments)this.bind("submit",e);else if(this.length){var n=t.Event("submit");this.eq(0).trigger(n),n.isDefaultPrevented()||this.get(0).submit()}return this}}(Zepto),function(t){"__proto__"in{}||t.extend(t.zepto,{Z:function(e,n){return e=e||[],t.extend(e,t.fn),e.selector=n||"",e.__Z=!0,e},isZ:function(e){return"array"===t.type(e)&&"__Z"in e}});try{getComputedStyle(void 0)}catch(e){var n=getComputedStyle;window.getComputedStyle=function(t){try{return n(t)}catch(e){return null}}}}(Zepto); -------------------------------------------------------------------------------- /myvue/src/js/vue-router.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by htzhanglong on 2017/2/6. 3 | */ 4 | /** 5 | * vue-router v2.2.0 6 | * (c) 2017 Evan You 7 | * @license MIT 8 | */ 9 | (function (global, factory) { 10 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 11 | typeof define === 'function' && define.amd ? define(factory) : 12 | (global.VueRouter = factory()); 13 | }(this, (function () { 'use strict'; 14 | 15 | /* */ 16 | 17 | function assert (condition, message) { 18 | if (!condition) { 19 | throw new Error(("[vue-router] " + message)) 20 | } 21 | } 22 | 23 | function warn (condition, message) { 24 | if (!condition) { 25 | typeof console !== 'undefined' && console.warn(("[vue-router] " + message)); 26 | } 27 | } 28 | 29 | var View = { 30 | name: 'router-view', 31 | functional: true, 32 | props: { 33 | name: { 34 | type: String, 35 | default: 'default' 36 | } 37 | }, 38 | render: function render (h, ref) { 39 | var props = ref.props; 40 | var children = ref.children; 41 | var parent = ref.parent; 42 | var data = ref.data; 43 | 44 | data.routerView = true; 45 | 46 | var name = props.name; 47 | var route = parent.$route; 48 | var cache = parent._routerViewCache || (parent._routerViewCache = {}); 49 | 50 | // determine current view depth, also check to see if the tree 51 | // has been toggled inactive but kept-alive. 52 | var depth = 0; 53 | var inactive = false; 54 | while (parent) { 55 | if (parent.$vnode && parent.$vnode.data.routerView) { 56 | depth++; 57 | } 58 | if (parent._inactive) { 59 | inactive = true; 60 | } 61 | parent = parent.$parent; 62 | } 63 | data.routerViewDepth = depth; 64 | 65 | // render previous view if the tree is inactive and kept-alive 66 | if (inactive) { 67 | return h(cache[name], data, children) 68 | } 69 | 70 | var matched = route.matched[depth]; 71 | // render empty node if no matched route 72 | if (!matched) { 73 | cache[name] = null; 74 | return h() 75 | } 76 | 77 | var component = cache[name] = matched.components[name]; 78 | 79 | // inject instance registration hooks 80 | var hooks = data.hook || (data.hook = {}); 81 | hooks.init = function (vnode) { 82 | matched.instances[name] = vnode.child; 83 | }; 84 | hooks.prepatch = function (oldVnode, vnode) { 85 | matched.instances[name] = vnode.child; 86 | }; 87 | hooks.destroy = function (vnode) { 88 | if (matched.instances[name] === vnode.child) { 89 | matched.instances[name] = undefined; 90 | } 91 | }; 92 | 93 | // resolve props 94 | data.props = resolveProps(route, matched.props && matched.props[name]); 95 | 96 | return h(component, data, children) 97 | } 98 | }; 99 | 100 | function resolveProps (route, config) { 101 | switch (typeof config) { 102 | case 'undefined': 103 | return 104 | case 'object': 105 | return config 106 | case 'function': 107 | return config(route) 108 | case 'boolean': 109 | return config ? route.params : undefined 110 | default: 111 | warn(false, ("props in \"" + (route.path) + "\" is a " + (typeof config) + ", expecting an object, function or boolean.")); 112 | } 113 | } 114 | 115 | /* */ 116 | 117 | var encodeReserveRE = /[!'()*]/g; 118 | var encodeReserveReplacer = function (c) { return '%' + c.charCodeAt(0).toString(16); }; 119 | var commaRE = /%2C/g; 120 | 121 | // fixed encodeURIComponent which is more comformant to RFC3986: 122 | // - escapes [!'()*] 123 | // - preserve commas 124 | var encode = function (str) { return encodeURIComponent(str) 125 | .replace(encodeReserveRE, encodeReserveReplacer) 126 | .replace(commaRE, ','); }; 127 | 128 | var decode = decodeURIComponent; 129 | 130 | function resolveQuery ( 131 | query, 132 | extraQuery 133 | ) { 134 | if ( extraQuery === void 0 ) extraQuery = {}; 135 | 136 | if (query) { 137 | var parsedQuery; 138 | try { 139 | parsedQuery = parseQuery(query); 140 | } catch (e) { 141 | "development" !== 'production' && warn(false, e.message); 142 | parsedQuery = {}; 143 | } 144 | for (var key in extraQuery) { 145 | parsedQuery[key] = extraQuery[key]; 146 | } 147 | return parsedQuery 148 | } else { 149 | return extraQuery 150 | } 151 | } 152 | 153 | function parseQuery (query) { 154 | var res = {}; 155 | 156 | query = query.trim().replace(/^(\?|#|&)/, ''); 157 | 158 | if (!query) { 159 | return res 160 | } 161 | 162 | query.split('&').forEach(function (param) { 163 | var parts = param.replace(/\+/g, ' ').split('='); 164 | var key = decode(parts.shift()); 165 | var val = parts.length > 0 166 | ? decode(parts.join('=')) 167 | : null; 168 | 169 | if (res[key] === undefined) { 170 | res[key] = val; 171 | } else if (Array.isArray(res[key])) { 172 | res[key].push(val); 173 | } else { 174 | res[key] = [res[key], val]; 175 | } 176 | }); 177 | 178 | return res 179 | } 180 | 181 | function stringifyQuery (obj) { 182 | var res = obj ? Object.keys(obj).map(function (key) { 183 | var val = obj[key]; 184 | 185 | if (val === undefined) { 186 | return '' 187 | } 188 | 189 | if (val === null) { 190 | return encode(key) 191 | } 192 | 193 | if (Array.isArray(val)) { 194 | var result = []; 195 | val.slice().forEach(function (val2) { 196 | if (val2 === undefined) { 197 | return 198 | } 199 | if (val2 === null) { 200 | result.push(encode(key)); 201 | } else { 202 | result.push(encode(key) + '=' + encode(val2)); 203 | } 204 | }); 205 | return result.join('&') 206 | } 207 | 208 | return encode(key) + '=' + encode(val) 209 | }).filter(function (x) { return x.length > 0; }).join('&') : null; 210 | return res ? ("?" + res) : '' 211 | } 212 | 213 | /* */ 214 | 215 | var trailingSlashRE = /\/?$/; 216 | 217 | function createRoute ( 218 | record, 219 | location, 220 | redirectedFrom 221 | ) { 222 | var route = { 223 | name: location.name || (record && record.name), 224 | meta: (record && record.meta) || {}, 225 | path: location.path || '/', 226 | hash: location.hash || '', 227 | query: location.query || {}, 228 | params: location.params || {}, 229 | fullPath: getFullPath(location), 230 | matched: record ? formatMatch(record) : [] 231 | }; 232 | if (redirectedFrom) { 233 | route.redirectedFrom = getFullPath(redirectedFrom); 234 | } 235 | return Object.freeze(route) 236 | } 237 | 238 | // the starting route that represents the initial state 239 | var START = createRoute(null, { 240 | path: '/' 241 | }); 242 | 243 | function formatMatch (record) { 244 | var res = []; 245 | while (record) { 246 | res.unshift(record); 247 | record = record.parent; 248 | } 249 | return res 250 | } 251 | 252 | function getFullPath (ref) { 253 | var path = ref.path; 254 | var query = ref.query; if ( query === void 0 ) query = {}; 255 | var hash = ref.hash; if ( hash === void 0 ) hash = ''; 256 | 257 | return (path || '/') + stringifyQuery(query) + hash 258 | } 259 | 260 | function isSameRoute (a, b) { 261 | if (b === START) { 262 | return a === b 263 | } else if (!b) { 264 | return false 265 | } else if (a.path && b.path) { 266 | return ( 267 | a.path.replace(trailingSlashRE, '') === b.path.replace(trailingSlashRE, '') && 268 | a.hash === b.hash && 269 | isObjectEqual(a.query, b.query) 270 | ) 271 | } else if (a.name && b.name) { 272 | return ( 273 | a.name === b.name && 274 | a.hash === b.hash && 275 | isObjectEqual(a.query, b.query) && 276 | isObjectEqual(a.params, b.params) 277 | ) 278 | } else { 279 | return false 280 | } 281 | } 282 | 283 | function isObjectEqual (a, b) { 284 | if ( a === void 0 ) a = {}; 285 | if ( b === void 0 ) b = {}; 286 | 287 | var aKeys = Object.keys(a); 288 | var bKeys = Object.keys(b); 289 | if (aKeys.length !== bKeys.length) { 290 | return false 291 | } 292 | return aKeys.every(function (key) { return String(a[key]) === String(b[key]); }) 293 | } 294 | 295 | function isIncludedRoute (current, target) { 296 | return ( 297 | current.path.replace(trailingSlashRE, '/').indexOf( 298 | target.path.replace(trailingSlashRE, '/') 299 | ) === 0 && 300 | (!target.hash || current.hash === target.hash) && 301 | queryIncludes(current.query, target.query) 302 | ) 303 | } 304 | 305 | function queryIncludes (current, target) { 306 | for (var key in target) { 307 | if (!(key in current)) { 308 | return false 309 | } 310 | } 311 | return true 312 | } 313 | 314 | /* */ 315 | 316 | // work around weird flow bug 317 | var toTypes = [String, Object]; 318 | var eventTypes = [String, Array]; 319 | 320 | var Link = { 321 | name: 'router-link', 322 | props: { 323 | to: { 324 | type: toTypes, 325 | required: true 326 | }, 327 | tag: { 328 | type: String, 329 | default: 'a' 330 | }, 331 | exact: Boolean, 332 | append: Boolean, 333 | replace: Boolean, 334 | activeClass: String, 335 | event: { 336 | type: eventTypes, 337 | default: 'click' 338 | } 339 | }, 340 | render: function render (h) { 341 | var this$1 = this; 342 | 343 | var router = this.$router; 344 | var current = this.$route; 345 | var ref = router.resolve(this.to, current, this.append); 346 | var location = ref.location; 347 | var route = ref.route; 348 | var href = ref.href; 349 | var classes = {}; 350 | var activeClass = this.activeClass || router.options.linkActiveClass || 'router-link-active'; 351 | var compareTarget = location.path ? createRoute(null, location) : route; 352 | classes[activeClass] = this.exact 353 | ? isSameRoute(current, compareTarget) 354 | : isIncludedRoute(current, compareTarget); 355 | 356 | var handler = function (e) { 357 | if (guardEvent(e)) { 358 | if (this$1.replace) { 359 | router.replace(location); 360 | } else { 361 | router.push(location); 362 | } 363 | } 364 | }; 365 | 366 | var on = { click: guardEvent }; 367 | if (Array.isArray(this.event)) { 368 | this.event.forEach(function (e) { on[e] = handler; }); 369 | } else { 370 | on[this.event] = handler; 371 | } 372 | 373 | var data = { 374 | class: classes 375 | }; 376 | 377 | if (this.tag === 'a') { 378 | data.on = on; 379 | data.attrs = { href: href }; 380 | } else { 381 | // find the first child and apply listener and href 382 | var a = findAnchor(this.$slots.default); 383 | if (a) { 384 | // in case the is a static node 385 | a.isStatic = false; 386 | var extend = _Vue.util.extend; 387 | var aData = a.data = extend({}, a.data); 388 | aData.on = on; 389 | var aAttrs = a.data.attrs = extend({}, a.data.attrs); 390 | aAttrs.href = href; 391 | } else { 392 | // doesn't have child, apply listener to self 393 | data.on = on; 394 | } 395 | } 396 | 397 | return h(this.tag, data, this.$slots.default) 398 | } 399 | }; 400 | 401 | function guardEvent (e) { 402 | // don't redirect with control keys 403 | if (e.metaKey || e.ctrlKey || e.shiftKey) { return } 404 | // don't redirect when preventDefault called 405 | if (e.defaultPrevented) { return } 406 | // don't redirect on right click 407 | if (e.button !== undefined && e.button !== 0) { return } 408 | // don't redirect if `target="_blank"` 409 | if (e.target && e.target.getAttribute) { 410 | var target = e.target.getAttribute('target'); 411 | if (/\b_blank\b/i.test(target)) { return } 412 | } 413 | // this may be a Weex event which doesn't have this method 414 | if (e.preventDefault) { 415 | e.preventDefault(); 416 | } 417 | return true 418 | } 419 | 420 | function findAnchor (children) { 421 | if (children) { 422 | var child; 423 | for (var i = 0; i < children.length; i++) { 424 | child = children[i]; 425 | if (child.tag === 'a') { 426 | return child 427 | } 428 | if (child.children && (child = findAnchor(child.children))) { 429 | return child 430 | } 431 | } 432 | } 433 | } 434 | 435 | var _Vue; 436 | 437 | function install (Vue) { 438 | if (install.installed) { return } 439 | install.installed = true; 440 | 441 | _Vue = Vue; 442 | 443 | Object.defineProperty(Vue.prototype, '$router', { 444 | get: function get () { return this.$root._router } 445 | }); 446 | 447 | Object.defineProperty(Vue.prototype, '$route', { 448 | get: function get () { return this.$root._route } 449 | }); 450 | 451 | Vue.mixin({ 452 | beforeCreate: function beforeCreate () { 453 | if (this.$options.router) { 454 | this._router = this.$options.router; 455 | this._router.init(this); 456 | Vue.util.defineReactive(this, '_route', this._router.history.current); 457 | } 458 | } 459 | }); 460 | 461 | Vue.component('router-view', View); 462 | Vue.component('router-link', Link); 463 | 464 | var strats = Vue.config.optionMergeStrategies; 465 | // use the same hook merging strategy for route hooks 466 | strats.beforeRouteEnter = strats.beforeRouteLeave = strats.created; 467 | } 468 | 469 | /* */ 470 | 471 | var inBrowser = typeof window !== 'undefined'; 472 | 473 | /* */ 474 | 475 | function resolvePath ( 476 | relative, 477 | base, 478 | append 479 | ) { 480 | if (relative.charAt(0) === '/') { 481 | return relative 482 | } 483 | 484 | if (relative.charAt(0) === '?' || relative.charAt(0) === '#') { 485 | return base + relative 486 | } 487 | 488 | var stack = base.split('/'); 489 | 490 | // remove trailing segment if: 491 | // - not appending 492 | // - appending to trailing slash (last segment is empty) 493 | if (!append || !stack[stack.length - 1]) { 494 | stack.pop(); 495 | } 496 | 497 | // resolve relative path 498 | var segments = relative.replace(/^\//, '').split('/'); 499 | for (var i = 0; i < segments.length; i++) { 500 | var segment = segments[i]; 501 | if (segment === '.') { 502 | continue 503 | } else if (segment === '..') { 504 | stack.pop(); 505 | } else { 506 | stack.push(segment); 507 | } 508 | } 509 | 510 | // ensure leading slash 511 | if (stack[0] !== '') { 512 | stack.unshift(''); 513 | } 514 | 515 | return stack.join('/') 516 | } 517 | 518 | function parsePath (path) { 519 | var hash = ''; 520 | var query = ''; 521 | 522 | var hashIndex = path.indexOf('#'); 523 | if (hashIndex >= 0) { 524 | hash = path.slice(hashIndex); 525 | path = path.slice(0, hashIndex); 526 | } 527 | 528 | var queryIndex = path.indexOf('?'); 529 | if (queryIndex >= 0) { 530 | query = path.slice(queryIndex + 1); 531 | path = path.slice(0, queryIndex); 532 | } 533 | 534 | return { 535 | path: path, 536 | query: query, 537 | hash: hash 538 | } 539 | } 540 | 541 | function cleanPath (path) { 542 | return path.replace(/\/\//g, '/') 543 | } 544 | 545 | /* */ 546 | 547 | function createRouteMap ( 548 | routes, 549 | oldPathMap, 550 | oldNameMap 551 | ) { 552 | var pathMap = oldPathMap || Object.create(null); 553 | var nameMap = oldNameMap || Object.create(null); 554 | 555 | routes.forEach(function (route) { 556 | addRouteRecord(pathMap, nameMap, route); 557 | }); 558 | 559 | return { 560 | pathMap: pathMap, 561 | nameMap: nameMap 562 | } 563 | } 564 | 565 | function addRouteRecord ( 566 | pathMap, 567 | nameMap, 568 | route, 569 | parent, 570 | matchAs 571 | ) { 572 | var path = route.path; 573 | var name = route.name; 574 | { 575 | assert(path != null, "\"path\" is required in a route configuration."); 576 | assert( 577 | typeof route.component !== 'string', 578 | "route config \"component\" for path: " + (String(path || name)) + " cannot be a " + 579 | "string id. Use an actual component instead." 580 | ); 581 | } 582 | 583 | var record = { 584 | path: normalizePath(path, parent), 585 | components: route.components || { default: route.component }, 586 | instances: {}, 587 | name: name, 588 | parent: parent, 589 | matchAs: matchAs, 590 | redirect: route.redirect, 591 | beforeEnter: route.beforeEnter, 592 | meta: route.meta || {}, 593 | props: route.props == null 594 | ? {} 595 | : route.components 596 | ? route.props 597 | : { default: route.props } 598 | }; 599 | 600 | if (route.children) { 601 | // Warn if route is named and has a default child route. 602 | // If users navigate to this route by name, the default child will 603 | // not be rendered (GH Issue #629) 604 | { 605 | if (route.name && route.children.some(function (child) { return /^\/?$/.test(child.path); })) { 606 | warn( 607 | false, 608 | "Named Route '" + (route.name) + "' has a default child route. " + 609 | "When navigating to this named route (:to=\"{name: '" + (route.name) + "'\"), " + 610 | "the default child route will not be rendered. Remove the name from " + 611 | "this route and use the name of the default child route for named " + 612 | "links instead." 613 | ); 614 | } 615 | } 616 | route.children.forEach(function (child) { 617 | var childMatchAs = matchAs 618 | ? cleanPath((matchAs + "/" + (child.path))) 619 | : undefined; 620 | addRouteRecord(pathMap, nameMap, child, record, childMatchAs); 621 | }); 622 | } 623 | 624 | if (route.alias !== undefined) { 625 | if (Array.isArray(route.alias)) { 626 | route.alias.forEach(function (alias) { 627 | var aliasRoute = { 628 | path: alias, 629 | children: route.children 630 | }; 631 | addRouteRecord(pathMap, nameMap, aliasRoute, parent, record.path); 632 | }); 633 | } else { 634 | var aliasRoute = { 635 | path: route.alias, 636 | children: route.children 637 | }; 638 | addRouteRecord(pathMap, nameMap, aliasRoute, parent, record.path); 639 | } 640 | } 641 | 642 | if (!pathMap[record.path]) { 643 | pathMap[record.path] = record; 644 | } 645 | 646 | if (name) { 647 | if (!nameMap[name]) { 648 | nameMap[name] = record; 649 | } else if ("development" !== 'production' && !matchAs) { 650 | warn( 651 | false, 652 | "Duplicate named routes definition: " + 653 | "{ name: \"" + name + "\", path: \"" + (record.path) + "\" }" 654 | ); 655 | } 656 | } 657 | } 658 | 659 | function normalizePath (path, parent) { 660 | path = path.replace(/\/$/, ''); 661 | if (path[0] === '/') { return path } 662 | if (parent == null) { return path } 663 | return cleanPath(((parent.path) + "/" + path)) 664 | } 665 | 666 | var index$1 = Array.isArray || function (arr) { 667 | return Object.prototype.toString.call(arr) == '[object Array]'; 668 | }; 669 | 670 | var isarray = index$1; 671 | 672 | /** 673 | * Expose `pathToRegexp`. 674 | */ 675 | var index = pathToRegexp; 676 | var parse_1 = parse; 677 | var compile_1 = compile; 678 | var tokensToFunction_1 = tokensToFunction; 679 | var tokensToRegExp_1 = tokensToRegExp; 680 | 681 | /** 682 | * The main path matching regexp utility. 683 | * 684 | * @type {RegExp} 685 | */ 686 | var PATH_REGEXP = new RegExp([ 687 | // Match escaped characters that would otherwise appear in future matches. 688 | // This allows the user to escape special characters that won't transform. 689 | '(\\\\.)', 690 | // Match Express-style parameters and un-named parameters with a prefix 691 | // and optional suffixes. Matches appear as: 692 | // 693 | // "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?", undefined] 694 | // "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined, undefined] 695 | // "/*" => ["/", undefined, undefined, undefined, undefined, "*"] 696 | '([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))' 697 | ].join('|'), 'g'); 698 | 699 | /** 700 | * Parse a string for the raw tokens. 701 | * 702 | * @param {string} str 703 | * @param {Object=} options 704 | * @return {!Array} 705 | */ 706 | function parse (str, options) { 707 | var tokens = []; 708 | var key = 0; 709 | var index = 0; 710 | var path = ''; 711 | var defaultDelimiter = options && options.delimiter || '/'; 712 | var res; 713 | 714 | while ((res = PATH_REGEXP.exec(str)) != null) { 715 | var m = res[0]; 716 | var escaped = res[1]; 717 | var offset = res.index; 718 | path += str.slice(index, offset); 719 | index = offset + m.length; 720 | 721 | // Ignore already escaped sequences. 722 | if (escaped) { 723 | path += escaped[1]; 724 | continue 725 | } 726 | 727 | var next = str[index]; 728 | var prefix = res[2]; 729 | var name = res[3]; 730 | var capture = res[4]; 731 | var group = res[5]; 732 | var modifier = res[6]; 733 | var asterisk = res[7]; 734 | 735 | // Push the current path onto the tokens. 736 | if (path) { 737 | tokens.push(path); 738 | path = ''; 739 | } 740 | 741 | var partial = prefix != null && next != null && next !== prefix; 742 | var repeat = modifier === '+' || modifier === '*'; 743 | var optional = modifier === '?' || modifier === '*'; 744 | var delimiter = res[2] || defaultDelimiter; 745 | var pattern = capture || group; 746 | 747 | tokens.push({ 748 | name: name || key++, 749 | prefix: prefix || '', 750 | delimiter: delimiter, 751 | optional: optional, 752 | repeat: repeat, 753 | partial: partial, 754 | asterisk: !!asterisk, 755 | pattern: pattern ? escapeGroup(pattern) : (asterisk ? '.*' : '[^' + escapeString(delimiter) + ']+?') 756 | }); 757 | } 758 | 759 | // Match any characters still remaining. 760 | if (index < str.length) { 761 | path += str.substr(index); 762 | } 763 | 764 | // If the path exists, push it onto the end. 765 | if (path) { 766 | tokens.push(path); 767 | } 768 | 769 | return tokens 770 | } 771 | 772 | /** 773 | * Compile a string to a template function for the path. 774 | * 775 | * @param {string} str 776 | * @param {Object=} options 777 | * @return {!function(Object=, Object=)} 778 | */ 779 | function compile (str, options) { 780 | return tokensToFunction(parse(str, options)) 781 | } 782 | 783 | /** 784 | * Prettier encoding of URI path segments. 785 | * 786 | * @param {string} 787 | * @return {string} 788 | */ 789 | function encodeURIComponentPretty (str) { 790 | return encodeURI(str).replace(/[\/?#]/g, function (c) { 791 | return '%' + c.charCodeAt(0).toString(16).toUpperCase() 792 | }) 793 | } 794 | 795 | /** 796 | * Encode the asterisk parameter. Similar to `pretty`, but allows slashes. 797 | * 798 | * @param {string} 799 | * @return {string} 800 | */ 801 | function encodeAsterisk (str) { 802 | return encodeURI(str).replace(/[?#]/g, function (c) { 803 | return '%' + c.charCodeAt(0).toString(16).toUpperCase() 804 | }) 805 | } 806 | 807 | /** 808 | * Expose a method for transforming tokens into the path function. 809 | */ 810 | function tokensToFunction (tokens) { 811 | // Compile all the tokens into regexps. 812 | var matches = new Array(tokens.length); 813 | 814 | // Compile all the patterns before compilation. 815 | for (var i = 0; i < tokens.length; i++) { 816 | if (typeof tokens[i] === 'object') { 817 | matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$'); 818 | } 819 | } 820 | 821 | return function (obj, opts) { 822 | var path = ''; 823 | var data = obj || {}; 824 | var options = opts || {}; 825 | var encode = options.pretty ? encodeURIComponentPretty : encodeURIComponent; 826 | 827 | for (var i = 0; i < tokens.length; i++) { 828 | var token = tokens[i]; 829 | 830 | if (typeof token === 'string') { 831 | path += token; 832 | 833 | continue 834 | } 835 | 836 | var value = data[token.name]; 837 | var segment; 838 | 839 | if (value == null) { 840 | if (token.optional) { 841 | // Prepend partial segment prefixes. 842 | if (token.partial) { 843 | path += token.prefix; 844 | } 845 | 846 | continue 847 | } else { 848 | throw new TypeError('Expected "' + token.name + '" to be defined') 849 | } 850 | } 851 | 852 | if (isarray(value)) { 853 | if (!token.repeat) { 854 | throw new TypeError('Expected "' + token.name + '" to not repeat, but received `' + JSON.stringify(value) + '`') 855 | } 856 | 857 | if (value.length === 0) { 858 | if (token.optional) { 859 | continue 860 | } else { 861 | throw new TypeError('Expected "' + token.name + '" to not be empty') 862 | } 863 | } 864 | 865 | for (var j = 0; j < value.length; j++) { 866 | segment = encode(value[j]); 867 | 868 | if (!matches[i].test(segment)) { 869 | throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '", but received `' + JSON.stringify(segment) + '`') 870 | } 871 | 872 | path += (j === 0 ? token.prefix : token.delimiter) + segment; 873 | } 874 | 875 | continue 876 | } 877 | 878 | segment = token.asterisk ? encodeAsterisk(value) : encode(value); 879 | 880 | if (!matches[i].test(segment)) { 881 | throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but received "' + segment + '"') 882 | } 883 | 884 | path += token.prefix + segment; 885 | } 886 | 887 | return path 888 | } 889 | } 890 | 891 | /** 892 | * Escape a regular expression string. 893 | * 894 | * @param {string} str 895 | * @return {string} 896 | */ 897 | function escapeString (str) { 898 | return str.replace(/([.+*?=^!:${}()[\]|\/\\])/g, '\\$1') 899 | } 900 | 901 | /** 902 | * Escape the capturing group by escaping special characters and meaning. 903 | * 904 | * @param {string} group 905 | * @return {string} 906 | */ 907 | function escapeGroup (group) { 908 | return group.replace(/([=!:$\/()])/g, '\\$1') 909 | } 910 | 911 | /** 912 | * Attach the keys as a property of the regexp. 913 | * 914 | * @param {!RegExp} re 915 | * @param {Array} keys 916 | * @return {!RegExp} 917 | */ 918 | function attachKeys (re, keys) { 919 | re.keys = keys; 920 | return re 921 | } 922 | 923 | /** 924 | * Get the flags for a regexp from the options. 925 | * 926 | * @param {Object} options 927 | * @return {string} 928 | */ 929 | function flags (options) { 930 | return options.sensitive ? '' : 'i' 931 | } 932 | 933 | /** 934 | * Pull out keys from a regexp. 935 | * 936 | * @param {!RegExp} path 937 | * @param {!Array} keys 938 | * @return {!RegExp} 939 | */ 940 | function regexpToRegexp (path, keys) { 941 | // Use a negative lookahead to match only capturing groups. 942 | var groups = path.source.match(/\((?!\?)/g); 943 | 944 | if (groups) { 945 | for (var i = 0; i < groups.length; i++) { 946 | keys.push({ 947 | name: i, 948 | prefix: null, 949 | delimiter: null, 950 | optional: false, 951 | repeat: false, 952 | partial: false, 953 | asterisk: false, 954 | pattern: null 955 | }); 956 | } 957 | } 958 | 959 | return attachKeys(path, keys) 960 | } 961 | 962 | /** 963 | * Transform an array into a regexp. 964 | * 965 | * @param {!Array} path 966 | * @param {Array} keys 967 | * @param {!Object} options 968 | * @return {!RegExp} 969 | */ 970 | function arrayToRegexp (path, keys, options) { 971 | var parts = []; 972 | 973 | for (var i = 0; i < path.length; i++) { 974 | parts.push(pathToRegexp(path[i], keys, options).source); 975 | } 976 | 977 | var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options)); 978 | 979 | return attachKeys(regexp, keys) 980 | } 981 | 982 | /** 983 | * Create a path regexp from string input. 984 | * 985 | * @param {string} path 986 | * @param {!Array} keys 987 | * @param {!Object} options 988 | * @return {!RegExp} 989 | */ 990 | function stringToRegexp (path, keys, options) { 991 | return tokensToRegExp(parse(path, options), keys, options) 992 | } 993 | 994 | /** 995 | * Expose a function for taking tokens and returning a RegExp. 996 | * 997 | * @param {!Array} tokens 998 | * @param {(Array|Object)=} keys 999 | * @param {Object=} options 1000 | * @return {!RegExp} 1001 | */ 1002 | function tokensToRegExp (tokens, keys, options) { 1003 | if (!isarray(keys)) { 1004 | options = /** @type {!Object} */ (keys || options); 1005 | keys = []; 1006 | } 1007 | 1008 | options = options || {}; 1009 | 1010 | var strict = options.strict; 1011 | var end = options.end !== false; 1012 | var route = ''; 1013 | 1014 | // Iterate over the tokens and create our regexp string. 1015 | for (var i = 0; i < tokens.length; i++) { 1016 | var token = tokens[i]; 1017 | 1018 | if (typeof token === 'string') { 1019 | route += escapeString(token); 1020 | } else { 1021 | var prefix = escapeString(token.prefix); 1022 | var capture = '(?:' + token.pattern + ')'; 1023 | 1024 | keys.push(token); 1025 | 1026 | if (token.repeat) { 1027 | capture += '(?:' + prefix + capture + ')*'; 1028 | } 1029 | 1030 | if (token.optional) { 1031 | if (!token.partial) { 1032 | capture = '(?:' + prefix + '(' + capture + '))?'; 1033 | } else { 1034 | capture = prefix + '(' + capture + ')?'; 1035 | } 1036 | } else { 1037 | capture = prefix + '(' + capture + ')'; 1038 | } 1039 | 1040 | route += capture; 1041 | } 1042 | } 1043 | 1044 | var delimiter = escapeString(options.delimiter || '/'); 1045 | var endsWithDelimiter = route.slice(-delimiter.length) === delimiter; 1046 | 1047 | // In non-strict mode we allow a slash at the end of match. If the path to 1048 | // match already ends with a slash, we remove it for consistency. The slash 1049 | // is valid at the end of a path match, not in the middle. This is important 1050 | // in non-ending mode, where "/test/" shouldn't match "/test//route". 1051 | if (!strict) { 1052 | route = (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) + '(?:' + delimiter + '(?=$))?'; 1053 | } 1054 | 1055 | if (end) { 1056 | route += '$'; 1057 | } else { 1058 | // In non-ending mode, we need the capturing groups to match as much as 1059 | // possible by using a positive lookahead to the end or next path segment. 1060 | route += strict && endsWithDelimiter ? '' : '(?=' + delimiter + '|$)'; 1061 | } 1062 | 1063 | return attachKeys(new RegExp('^' + route, flags(options)), keys) 1064 | } 1065 | 1066 | /** 1067 | * Normalize the given path string, returning a regular expression. 1068 | * 1069 | * An empty array can be passed in for the keys, which will hold the 1070 | * placeholder key descriptions. For example, using `/user/:id`, `keys` will 1071 | * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`. 1072 | * 1073 | * @param {(string|RegExp|Array)} path 1074 | * @param {(Array|Object)=} keys 1075 | * @param {Object=} options 1076 | * @return {!RegExp} 1077 | */ 1078 | function pathToRegexp (path, keys, options) { 1079 | if (!isarray(keys)) { 1080 | options = /** @type {!Object} */ (keys || options); 1081 | keys = []; 1082 | } 1083 | 1084 | options = options || {}; 1085 | 1086 | if (path instanceof RegExp) { 1087 | return regexpToRegexp(path, /** @type {!Array} */ (keys)) 1088 | } 1089 | 1090 | if (isarray(path)) { 1091 | return arrayToRegexp(/** @type {!Array} */ (path), /** @type {!Array} */ (keys), options) 1092 | } 1093 | 1094 | return stringToRegexp(/** @type {string} */ (path), /** @type {!Array} */ (keys), options) 1095 | } 1096 | 1097 | index.parse = parse_1; 1098 | index.compile = compile_1; 1099 | index.tokensToFunction = tokensToFunction_1; 1100 | index.tokensToRegExp = tokensToRegExp_1; 1101 | 1102 | /* */ 1103 | 1104 | var regexpCache = Object.create(null); 1105 | 1106 | function getRouteRegex (path) { 1107 | var hit = regexpCache[path]; 1108 | var keys, regexp; 1109 | 1110 | if (hit) { 1111 | keys = hit.keys; 1112 | regexp = hit.regexp; 1113 | } else { 1114 | keys = []; 1115 | regexp = index(path, keys); 1116 | regexpCache[path] = { keys: keys, regexp: regexp }; 1117 | } 1118 | 1119 | return { keys: keys, regexp: regexp } 1120 | } 1121 | 1122 | var regexpCompileCache = Object.create(null); 1123 | 1124 | function fillParams ( 1125 | path, 1126 | params, 1127 | routeMsg 1128 | ) { 1129 | try { 1130 | var filler = 1131 | regexpCompileCache[path] || 1132 | (regexpCompileCache[path] = index.compile(path)); 1133 | return filler(params || {}, { pretty: true }) 1134 | } catch (e) { 1135 | { 1136 | warn(false, ("missing param for " + routeMsg + ": " + (e.message))); 1137 | } 1138 | return '' 1139 | } 1140 | } 1141 | 1142 | /* */ 1143 | 1144 | function normalizeLocation ( 1145 | raw, 1146 | current, 1147 | append 1148 | ) { 1149 | var next = typeof raw === 'string' ? { path: raw } : raw; 1150 | // named target 1151 | if (next.name || next._normalized) { 1152 | return next 1153 | } 1154 | 1155 | // relative params 1156 | if (!next.path && next.params && current) { 1157 | next = assign({}, next); 1158 | next._normalized = true; 1159 | var params = assign(assign({}, current.params), next.params); 1160 | if (current.name) { 1161 | next.name = current.name; 1162 | next.params = params; 1163 | } else if (current.matched) { 1164 | var rawPath = current.matched[current.matched.length - 1].path; 1165 | next.path = fillParams(rawPath, params, ("path " + (current.path))); 1166 | } else { 1167 | warn(false, "relative params navigation requires a current route."); 1168 | } 1169 | return next 1170 | } 1171 | 1172 | var parsedPath = parsePath(next.path || ''); 1173 | var basePath = (current && current.path) || '/'; 1174 | var path = parsedPath.path 1175 | ? resolvePath(parsedPath.path, basePath, append || next.append) 1176 | : (current && current.path) || '/'; 1177 | var query = resolveQuery(parsedPath.query, next.query); 1178 | var hash = next.hash || parsedPath.hash; 1179 | if (hash && hash.charAt(0) !== '#') { 1180 | hash = "#" + hash; 1181 | } 1182 | 1183 | return { 1184 | _normalized: true, 1185 | path: path, 1186 | query: query, 1187 | hash: hash 1188 | } 1189 | } 1190 | 1191 | function assign (a, b) { 1192 | for (var key in b) { 1193 | a[key] = b[key]; 1194 | } 1195 | return a 1196 | } 1197 | 1198 | /* */ 1199 | 1200 | function createMatcher (routes) { 1201 | var ref = createRouteMap(routes); 1202 | var pathMap = ref.pathMap; 1203 | var nameMap = ref.nameMap; 1204 | 1205 | function addRoutes (routes) { 1206 | createRouteMap(routes, pathMap, nameMap); 1207 | } 1208 | 1209 | function match ( 1210 | raw, 1211 | currentRoute, 1212 | redirectedFrom 1213 | ) { 1214 | var location = normalizeLocation(raw, currentRoute); 1215 | var name = location.name; 1216 | 1217 | if (name) { 1218 | var record = nameMap[name]; 1219 | { 1220 | warn(record, ("Route with name '" + name + "' does not exist")); 1221 | } 1222 | var paramNames = getRouteRegex(record.path).keys 1223 | .filter(function (key) { return !key.optional; }) 1224 | .map(function (key) { return key.name; }); 1225 | 1226 | if (typeof location.params !== 'object') { 1227 | location.params = {}; 1228 | } 1229 | 1230 | if (currentRoute && typeof currentRoute.params === 'object') { 1231 | for (var key in currentRoute.params) { 1232 | if (!(key in location.params) && paramNames.indexOf(key) > -1) { 1233 | location.params[key] = currentRoute.params[key]; 1234 | } 1235 | } 1236 | } 1237 | 1238 | if (record) { 1239 | location.path = fillParams(record.path, location.params, ("named route \"" + name + "\"")); 1240 | return _createRoute(record, location, redirectedFrom) 1241 | } 1242 | } else if (location.path) { 1243 | location.params = {}; 1244 | for (var path in pathMap) { 1245 | if (matchRoute(path, location.params, location.path)) { 1246 | return _createRoute(pathMap[path], location, redirectedFrom) 1247 | } 1248 | } 1249 | } 1250 | // no match 1251 | return _createRoute(null, location) 1252 | } 1253 | 1254 | function redirect ( 1255 | record, 1256 | location 1257 | ) { 1258 | var originalRedirect = record.redirect; 1259 | var redirect = typeof originalRedirect === 'function' 1260 | ? originalRedirect(createRoute(record, location)) 1261 | : originalRedirect; 1262 | 1263 | if (typeof redirect === 'string') { 1264 | redirect = { path: redirect }; 1265 | } 1266 | 1267 | if (!redirect || typeof redirect !== 'object') { 1268 | "development" !== 'production' && warn( 1269 | false, ("invalid redirect option: " + (JSON.stringify(redirect))) 1270 | ); 1271 | return _createRoute(null, location) 1272 | } 1273 | 1274 | var re = redirect; 1275 | var name = re.name; 1276 | var path = re.path; 1277 | var query = location.query; 1278 | var hash = location.hash; 1279 | var params = location.params; 1280 | query = re.hasOwnProperty('query') ? re.query : query; 1281 | hash = re.hasOwnProperty('hash') ? re.hash : hash; 1282 | params = re.hasOwnProperty('params') ? re.params : params; 1283 | 1284 | if (name) { 1285 | // resolved named direct 1286 | var targetRecord = nameMap[name]; 1287 | { 1288 | assert(targetRecord, ("redirect failed: named route \"" + name + "\" not found.")); 1289 | } 1290 | return match({ 1291 | _normalized: true, 1292 | name: name, 1293 | query: query, 1294 | hash: hash, 1295 | params: params 1296 | }, undefined, location) 1297 | } else if (path) { 1298 | // 1. resolve relative redirect 1299 | var rawPath = resolveRecordPath(path, record); 1300 | // 2. resolve params 1301 | var resolvedPath = fillParams(rawPath, params, ("redirect route with path \"" + rawPath + "\"")); 1302 | // 3. rematch with existing query and hash 1303 | return match({ 1304 | _normalized: true, 1305 | path: resolvedPath, 1306 | query: query, 1307 | hash: hash 1308 | }, undefined, location) 1309 | } else { 1310 | warn(false, ("invalid redirect option: " + (JSON.stringify(redirect)))); 1311 | return _createRoute(null, location) 1312 | } 1313 | } 1314 | 1315 | function alias ( 1316 | record, 1317 | location, 1318 | matchAs 1319 | ) { 1320 | var aliasedPath = fillParams(matchAs, location.params, ("aliased route with path \"" + matchAs + "\"")); 1321 | var aliasedMatch = match({ 1322 | _normalized: true, 1323 | path: aliasedPath 1324 | }); 1325 | if (aliasedMatch) { 1326 | var matched = aliasedMatch.matched; 1327 | var aliasedRecord = matched[matched.length - 1]; 1328 | location.params = aliasedMatch.params; 1329 | return _createRoute(aliasedRecord, location) 1330 | } 1331 | return _createRoute(null, location) 1332 | } 1333 | 1334 | function _createRoute ( 1335 | record, 1336 | location, 1337 | redirectedFrom 1338 | ) { 1339 | if (record && record.redirect) { 1340 | return redirect(record, redirectedFrom || location) 1341 | } 1342 | if (record && record.matchAs) { 1343 | return alias(record, location, record.matchAs) 1344 | } 1345 | return createRoute(record, location, redirectedFrom) 1346 | } 1347 | 1348 | return { 1349 | match: match, 1350 | addRoutes: addRoutes 1351 | } 1352 | } 1353 | 1354 | function matchRoute ( 1355 | path, 1356 | params, 1357 | pathname 1358 | ) { 1359 | var ref = getRouteRegex(path); 1360 | var regexp = ref.regexp; 1361 | var keys = ref.keys; 1362 | var m = pathname.match(regexp); 1363 | 1364 | if (!m) { 1365 | return false 1366 | } else if (!params) { 1367 | return true 1368 | } 1369 | 1370 | for (var i = 1, len = m.length; i < len; ++i) { 1371 | var key = keys[i - 1]; 1372 | var val = typeof m[i] === 'string' ? decodeURIComponent(m[i]) : m[i]; 1373 | if (key) { params[key.name] = val; } 1374 | } 1375 | 1376 | return true 1377 | } 1378 | 1379 | function resolveRecordPath (path, record) { 1380 | return resolvePath(path, record.parent ? record.parent.path : '/', true) 1381 | } 1382 | 1383 | /* */ 1384 | 1385 | 1386 | var positionStore = Object.create(null); 1387 | 1388 | function setupScroll () { 1389 | window.addEventListener('popstate', function (e) { 1390 | if (e.state && e.state.key) { 1391 | setStateKey(e.state.key); 1392 | } 1393 | }); 1394 | 1395 | window.addEventListener('scroll', saveScrollPosition); 1396 | } 1397 | 1398 | function handleScroll ( 1399 | router, 1400 | to, 1401 | from, 1402 | isPop 1403 | ) { 1404 | if (!router.app) { 1405 | return 1406 | } 1407 | 1408 | var behavior = router.options.scrollBehavior; 1409 | if (!behavior) { 1410 | return 1411 | } 1412 | 1413 | { 1414 | assert(typeof behavior === 'function', "scrollBehavior must be a function"); 1415 | } 1416 | 1417 | // wait until re-render finishes before scrolling 1418 | router.app.$nextTick(function () { 1419 | var position = getScrollPosition(); 1420 | var shouldScroll = behavior(to, from, isPop ? position : null); 1421 | if (!shouldScroll) { 1422 | return 1423 | } 1424 | var isObject = typeof shouldScroll === 'object'; 1425 | if (isObject && typeof shouldScroll.selector === 'string') { 1426 | var el = document.querySelector(shouldScroll.selector); 1427 | if (el) { 1428 | position = getElementPosition(el); 1429 | } else if (isValidPosition(shouldScroll)) { 1430 | position = normalizePosition(shouldScroll); 1431 | } 1432 | } else if (isObject && isValidPosition(shouldScroll)) { 1433 | position = normalizePosition(shouldScroll); 1434 | } 1435 | 1436 | if (position) { 1437 | window.scrollTo(position.x, position.y); 1438 | } 1439 | }); 1440 | } 1441 | 1442 | function saveScrollPosition () { 1443 | var key = getStateKey(); 1444 | if (key) { 1445 | positionStore[key] = { 1446 | x: window.pageXOffset, 1447 | y: window.pageYOffset 1448 | }; 1449 | } 1450 | } 1451 | 1452 | function getScrollPosition () { 1453 | var key = getStateKey(); 1454 | if (key) { 1455 | return positionStore[key] 1456 | } 1457 | } 1458 | 1459 | function getElementPosition (el) { 1460 | var docRect = document.documentElement.getBoundingClientRect(); 1461 | var elRect = el.getBoundingClientRect(); 1462 | return { 1463 | x: elRect.left - docRect.left, 1464 | y: elRect.top - docRect.top 1465 | } 1466 | } 1467 | 1468 | function isValidPosition (obj) { 1469 | return isNumber(obj.x) || isNumber(obj.y) 1470 | } 1471 | 1472 | function normalizePosition (obj) { 1473 | return { 1474 | x: isNumber(obj.x) ? obj.x : window.pageXOffset, 1475 | y: isNumber(obj.y) ? obj.y : window.pageYOffset 1476 | } 1477 | } 1478 | 1479 | function isNumber (v) { 1480 | return typeof v === 'number' 1481 | } 1482 | 1483 | /* */ 1484 | 1485 | var supportsPushState = inBrowser && (function () { 1486 | var ua = window.navigator.userAgent; 1487 | 1488 | if ( 1489 | (ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) && 1490 | ua.indexOf('Mobile Safari') !== -1 && 1491 | ua.indexOf('Chrome') === -1 && 1492 | ua.indexOf('Windows Phone') === -1 1493 | ) { 1494 | return false 1495 | } 1496 | 1497 | return window.history && 'pushState' in window.history 1498 | })(); 1499 | 1500 | // use User Timing api (if present) for more accurate key precision 1501 | var Time = inBrowser && window.performance && window.performance.now 1502 | ? window.performance 1503 | : Date; 1504 | 1505 | var _key = genKey(); 1506 | 1507 | function genKey () { 1508 | return Time.now().toFixed(3) 1509 | } 1510 | 1511 | function getStateKey () { 1512 | return _key 1513 | } 1514 | 1515 | function setStateKey (key) { 1516 | _key = key; 1517 | } 1518 | 1519 | function pushState (url, replace) { 1520 | // try...catch the pushState call to get around Safari 1521 | // DOM Exception 18 where it limits to 100 pushState calls 1522 | var history = window.history; 1523 | try { 1524 | if (replace) { 1525 | history.replaceState({ key: _key }, '', url); 1526 | } else { 1527 | _key = genKey(); 1528 | history.pushState({ key: _key }, '', url); 1529 | } 1530 | saveScrollPosition(); 1531 | } catch (e) { 1532 | window.location[replace ? 'replace' : 'assign'](url); 1533 | } 1534 | } 1535 | 1536 | function replaceState (url) { 1537 | pushState(url, true); 1538 | } 1539 | 1540 | /* */ 1541 | 1542 | function runQueue (queue, fn, cb) { 1543 | var step = function (index) { 1544 | if (index >= queue.length) { 1545 | cb(); 1546 | } else { 1547 | if (queue[index]) { 1548 | fn(queue[index], function () { 1549 | step(index + 1); 1550 | }); 1551 | } else { 1552 | step(index + 1); 1553 | } 1554 | } 1555 | }; 1556 | step(0); 1557 | } 1558 | 1559 | /* */ 1560 | 1561 | 1562 | var History = function History (router, base) { 1563 | this.router = router; 1564 | this.base = normalizeBase(base); 1565 | // start with a route object that stands for "nowhere" 1566 | this.current = START; 1567 | this.pending = null; 1568 | this.ready = false; 1569 | this.readyCbs = []; 1570 | }; 1571 | 1572 | History.prototype.listen = function listen (cb) { 1573 | this.cb = cb; 1574 | }; 1575 | 1576 | History.prototype.onReady = function onReady (cb) { 1577 | if (this.ready) { 1578 | cb(); 1579 | } else { 1580 | this.readyCbs.push(cb); 1581 | } 1582 | }; 1583 | 1584 | History.prototype.transitionTo = function transitionTo (location, onComplete, onAbort) { 1585 | var this$1 = this; 1586 | 1587 | var route = this.router.match(location, this.current); 1588 | this.confirmTransition(route, function () { 1589 | this$1.updateRoute(route); 1590 | onComplete && onComplete(route); 1591 | this$1.ensureURL(); 1592 | 1593 | // fire ready cbs once 1594 | if (!this$1.ready) { 1595 | this$1.ready = true; 1596 | this$1.readyCbs.forEach(function (cb) { 1597 | cb(route); 1598 | }); 1599 | } 1600 | }, onAbort); 1601 | }; 1602 | 1603 | History.prototype.confirmTransition = function confirmTransition (route, onComplete, onAbort) { 1604 | var this$1 = this; 1605 | 1606 | var current = this.current; 1607 | var abort = function () { onAbort && onAbort(); }; 1608 | if ( 1609 | isSameRoute(route, current) && 1610 | // in the case the route map has been dynamically appended to 1611 | route.matched.length === current.matched.length 1612 | ) { 1613 | this.ensureURL(); 1614 | return abort() 1615 | } 1616 | 1617 | var ref = resolveQueue(this.current.matched, route.matched); 1618 | var updated = ref.updated; 1619 | var deactivated = ref.deactivated; 1620 | var activated = ref.activated; 1621 | 1622 | var queue = [].concat( 1623 | // in-component leave guards 1624 | extractLeaveGuards(deactivated), 1625 | // global before hooks 1626 | this.router.beforeHooks, 1627 | // in-component update hooks 1628 | extractUpdateHooks(updated), 1629 | // in-config enter guards 1630 | activated.map(function (m) { return m.beforeEnter; }), 1631 | // async components 1632 | resolveAsyncComponents(activated) 1633 | ); 1634 | 1635 | this.pending = route; 1636 | var iterator = function (hook, next) { 1637 | if (this$1.pending !== route) { 1638 | return abort() 1639 | } 1640 | hook(route, current, function (to) { 1641 | if (to === false) { 1642 | // next(false) -> abort navigation, ensure current URL 1643 | this$1.ensureURL(true); 1644 | abort(); 1645 | } else if (typeof to === 'string' || typeof to === 'object') { 1646 | // next('/') or next({ path: '/' }) -> redirect 1647 | (typeof to === 'object' && to.replace) ? this$1.replace(to) : this$1.push(to); 1648 | abort(); 1649 | } else { 1650 | // confirm transition and pass on the value 1651 | next(to); 1652 | } 1653 | }); 1654 | }; 1655 | 1656 | runQueue(queue, iterator, function () { 1657 | var postEnterCbs = []; 1658 | var isValid = function () { return this$1.current === route; }; 1659 | var enterGuards = extractEnterGuards(activated, postEnterCbs, isValid); 1660 | // wait until async components are resolved before 1661 | // extracting in-component enter guards 1662 | runQueue(enterGuards, iterator, function () { 1663 | if (this$1.pending !== route) { 1664 | return abort() 1665 | } 1666 | this$1.pending = null; 1667 | onComplete(route); 1668 | if (this$1.router.app) { 1669 | this$1.router.app.$nextTick(function () { 1670 | postEnterCbs.forEach(function (cb) { return cb(); }); 1671 | }); 1672 | } 1673 | }); 1674 | }); 1675 | }; 1676 | 1677 | History.prototype.updateRoute = function updateRoute (route) { 1678 | var prev = this.current; 1679 | this.current = route; 1680 | this.cb && this.cb(route); 1681 | this.router.afterHooks.forEach(function (hook) { 1682 | hook && hook(route, prev); 1683 | }); 1684 | }; 1685 | 1686 | function normalizeBase (base) { 1687 | if (!base) { 1688 | if (inBrowser) { 1689 | // respect tag 1690 | var baseEl = document.querySelector('base'); 1691 | base = baseEl ? baseEl.getAttribute('href') : '/'; 1692 | } else { 1693 | base = '/'; 1694 | } 1695 | } 1696 | // make sure there's the starting slash 1697 | if (base.charAt(0) !== '/') { 1698 | base = '/' + base; 1699 | } 1700 | // remove trailing slash 1701 | return base.replace(/\/$/, '') 1702 | } 1703 | 1704 | function resolveQueue ( 1705 | current, 1706 | next 1707 | ) { 1708 | var i; 1709 | var max = Math.max(current.length, next.length); 1710 | for (i = 0; i < max; i++) { 1711 | if (current[i] !== next[i]) { 1712 | break 1713 | } 1714 | } 1715 | return { 1716 | updated: next.slice(0, i), 1717 | activated: next.slice(i), 1718 | deactivated: current.slice(i) 1719 | } 1720 | } 1721 | 1722 | function extractGuards ( 1723 | records, 1724 | name, 1725 | bind, 1726 | reverse 1727 | ) { 1728 | var guards = flatMapComponents(records, function (def, instance, match, key) { 1729 | var guard = extractGuard(def, name); 1730 | if (guard) { 1731 | return Array.isArray(guard) 1732 | ? guard.map(function (guard) { return bind(guard, instance, match, key); }) 1733 | : bind(guard, instance, match, key) 1734 | } 1735 | }); 1736 | return flatten(reverse ? guards.reverse() : guards) 1737 | } 1738 | 1739 | function extractGuard ( 1740 | def, 1741 | key 1742 | ) { 1743 | if (typeof def !== 'function') { 1744 | // extend now so that global mixins are applied. 1745 | def = _Vue.extend(def); 1746 | } 1747 | return def.options[key] 1748 | } 1749 | 1750 | function extractLeaveGuards (deactivated) { 1751 | return extractGuards(deactivated, 'beforeRouteLeave', bindGuard, true) 1752 | } 1753 | 1754 | function extractUpdateHooks (updated) { 1755 | return extractGuards(updated, 'beforeRouteUpdate', bindGuard) 1756 | } 1757 | 1758 | function bindGuard (guard, instance) { 1759 | return function boundRouteGuard () { 1760 | return guard.apply(instance, arguments) 1761 | } 1762 | } 1763 | 1764 | function extractEnterGuards ( 1765 | activated, 1766 | cbs, 1767 | isValid 1768 | ) { 1769 | return extractGuards(activated, 'beforeRouteEnter', function (guard, _, match, key) { 1770 | return bindEnterGuard(guard, match, key, cbs, isValid) 1771 | }) 1772 | } 1773 | 1774 | function bindEnterGuard ( 1775 | guard, 1776 | match, 1777 | key, 1778 | cbs, 1779 | isValid 1780 | ) { 1781 | return function routeEnterGuard (to, from, next) { 1782 | return guard(to, from, function (cb) { 1783 | next(cb); 1784 | if (typeof cb === 'function') { 1785 | cbs.push(function () { 1786 | // #750 1787 | // if a router-view is wrapped with an out-in transition, 1788 | // the instance may not have been registered at this time. 1789 | // we will need to poll for registration until current route 1790 | // is no longer valid. 1791 | poll(cb, match.instances, key, isValid); 1792 | }); 1793 | } 1794 | }) 1795 | } 1796 | } 1797 | 1798 | function poll ( 1799 | cb, // somehow flow cannot infer this is a function 1800 | instances, 1801 | key, 1802 | isValid 1803 | ) { 1804 | if (instances[key]) { 1805 | cb(instances[key]); 1806 | } else if (isValid()) { 1807 | setTimeout(function () { 1808 | poll(cb, instances, key, isValid); 1809 | }, 16); 1810 | } 1811 | } 1812 | 1813 | function resolveAsyncComponents (matched) { 1814 | return flatMapComponents(matched, function (def, _, match, key) { 1815 | // if it's a function and doesn't have Vue options attached, 1816 | // assume it's an async component resolve function. 1817 | // we are not using Vue's default async resolving mechanism because 1818 | // we want to halt the navigation until the incoming component has been 1819 | // resolved. 1820 | if (typeof def === 'function' && !def.options) { 1821 | return function (to, from, next) { 1822 | var resolve = once(function (resolvedDef) { 1823 | match.components[key] = resolvedDef; 1824 | next(); 1825 | }); 1826 | 1827 | var reject = once(function (reason) { 1828 | warn(false, ("Failed to resolve async component " + key + ": " + reason)); 1829 | next(false); 1830 | }); 1831 | 1832 | var res = def(resolve, reject); 1833 | if (res && typeof res.then === 'function') { 1834 | res.then(resolve, reject); 1835 | } 1836 | } 1837 | } 1838 | }) 1839 | } 1840 | 1841 | function flatMapComponents ( 1842 | matched, 1843 | fn 1844 | ) { 1845 | return flatten(matched.map(function (m) { 1846 | return Object.keys(m.components).map(function (key) { return fn( 1847 | m.components[key], 1848 | m.instances[key], 1849 | m, key 1850 | ); }) 1851 | })) 1852 | } 1853 | 1854 | function flatten (arr) { 1855 | return Array.prototype.concat.apply([], arr) 1856 | } 1857 | 1858 | // in Webpack 2, require.ensure now also returns a Promise 1859 | // so the resolve/reject functions may get called an extra time 1860 | // if the user uses an arrow function shorthand that happens to 1861 | // return that Promise. 1862 | function once (fn) { 1863 | var called = false; 1864 | return function () { 1865 | if (called) { return } 1866 | called = true; 1867 | return fn.apply(this, arguments) 1868 | } 1869 | } 1870 | 1871 | /* */ 1872 | 1873 | 1874 | var HTML5History = (function (History$$1) { 1875 | function HTML5History (router, base) { 1876 | var this$1 = this; 1877 | 1878 | History$$1.call(this, router, base); 1879 | 1880 | var expectScroll = router.options.scrollBehavior; 1881 | 1882 | if (expectScroll) { 1883 | setupScroll(); 1884 | } 1885 | 1886 | window.addEventListener('popstate', function (e) { 1887 | this$1.transitionTo(getLocation(this$1.base), function (route) { 1888 | if (expectScroll) { 1889 | handleScroll(router, route, this$1.current, true); 1890 | } 1891 | }); 1892 | }); 1893 | } 1894 | 1895 | if ( History$$1 ) HTML5History.__proto__ = History$$1; 1896 | HTML5History.prototype = Object.create( History$$1 && History$$1.prototype ); 1897 | HTML5History.prototype.constructor = HTML5History; 1898 | 1899 | HTML5History.prototype.go = function go (n) { 1900 | window.history.go(n); 1901 | }; 1902 | 1903 | HTML5History.prototype.push = function push (location, onComplete, onAbort) { 1904 | var this$1 = this; 1905 | 1906 | this.transitionTo(location, function (route) { 1907 | pushState(cleanPath(this$1.base + route.fullPath)); 1908 | handleScroll(this$1.router, route, this$1.current, false); 1909 | onComplete && onComplete(route); 1910 | }, onAbort); 1911 | }; 1912 | 1913 | HTML5History.prototype.replace = function replace (location, onComplete, onAbort) { 1914 | var this$1 = this; 1915 | 1916 | this.transitionTo(location, function (route) { 1917 | replaceState(cleanPath(this$1.base + route.fullPath)); 1918 | handleScroll(this$1.router, route, this$1.current, false); 1919 | onComplete && onComplete(route); 1920 | }, onAbort); 1921 | }; 1922 | 1923 | HTML5History.prototype.ensureURL = function ensureURL (push) { 1924 | if (getLocation(this.base) !== this.current.fullPath) { 1925 | var current = cleanPath(this.base + this.current.fullPath); 1926 | push ? pushState(current) : replaceState(current); 1927 | } 1928 | }; 1929 | 1930 | HTML5History.prototype.getCurrentLocation = function getCurrentLocation () { 1931 | return getLocation(this.base) 1932 | }; 1933 | 1934 | return HTML5History; 1935 | }(History)); 1936 | 1937 | function getLocation (base) { 1938 | var path = window.location.pathname; 1939 | if (base && path.indexOf(base) === 0) { 1940 | path = path.slice(base.length); 1941 | } 1942 | return (path || '/') + window.location.search + window.location.hash 1943 | } 1944 | 1945 | /* */ 1946 | 1947 | 1948 | var HashHistory = (function (History$$1) { 1949 | function HashHistory (router, base, fallback) { 1950 | History$$1.call(this, router, base); 1951 | // check history fallback deeplinking 1952 | if (fallback && checkFallback(this.base)) { 1953 | return 1954 | } 1955 | ensureSlash(); 1956 | } 1957 | 1958 | if ( History$$1 ) HashHistory.__proto__ = History$$1; 1959 | HashHistory.prototype = Object.create( History$$1 && History$$1.prototype ); 1960 | HashHistory.prototype.constructor = HashHistory; 1961 | 1962 | // this is delayed until the app mounts 1963 | // to avoid the hashchange listener being fired too early 1964 | HashHistory.prototype.setupListeners = function setupListeners () { 1965 | var this$1 = this; 1966 | 1967 | window.addEventListener('hashchange', function () { 1968 | if (!ensureSlash()) { 1969 | return 1970 | } 1971 | this$1.transitionTo(getHash(), function (route) { 1972 | replaceHash(route.fullPath); 1973 | }); 1974 | }); 1975 | }; 1976 | 1977 | HashHistory.prototype.push = function push (location, onComplete, onAbort) { 1978 | this.transitionTo(location, function (route) { 1979 | pushHash(route.fullPath); 1980 | onComplete && onComplete(route); 1981 | }, onAbort); 1982 | }; 1983 | 1984 | HashHistory.prototype.replace = function replace (location, onComplete, onAbort) { 1985 | this.transitionTo(location, function (route) { 1986 | replaceHash(route.fullPath); 1987 | onComplete && onComplete(route); 1988 | }, onAbort); 1989 | }; 1990 | 1991 | HashHistory.prototype.go = function go (n) { 1992 | window.history.go(n); 1993 | }; 1994 | 1995 | HashHistory.prototype.ensureURL = function ensureURL (push) { 1996 | var current = this.current.fullPath; 1997 | if (getHash() !== current) { 1998 | push ? pushHash(current) : replaceHash(current); 1999 | } 2000 | }; 2001 | 2002 | HashHistory.prototype.getCurrentLocation = function getCurrentLocation () { 2003 | return getHash() 2004 | }; 2005 | 2006 | return HashHistory; 2007 | }(History)); 2008 | 2009 | function checkFallback (base) { 2010 | var location = getLocation(base); 2011 | if (!/^\/#/.test(location)) { 2012 | window.location.replace( 2013 | cleanPath(base + '/#' + location) 2014 | ); 2015 | return true 2016 | } 2017 | } 2018 | 2019 | function ensureSlash () { 2020 | var path = getHash(); 2021 | if (path.charAt(0) === '/') { 2022 | return true 2023 | } 2024 | replaceHash('/' + path); 2025 | return false 2026 | } 2027 | 2028 | function getHash () { 2029 | // We can't use window.location.hash here because it's not 2030 | // consistent across browsers - Firefox will pre-decode it! 2031 | var href = window.location.href; 2032 | var index = href.indexOf('#'); 2033 | return index === -1 ? '' : href.slice(index + 1) 2034 | } 2035 | 2036 | function pushHash (path) { 2037 | window.location.hash = path; 2038 | } 2039 | 2040 | function replaceHash (path) { 2041 | var i = window.location.href.indexOf('#'); 2042 | window.location.replace( 2043 | window.location.href.slice(0, i >= 0 ? i : 0) + '#' + path 2044 | ); 2045 | } 2046 | 2047 | /* */ 2048 | 2049 | 2050 | var AbstractHistory = (function (History$$1) { 2051 | function AbstractHistory (router, base) { 2052 | History$$1.call(this, router, base); 2053 | this.stack = []; 2054 | this.index = -1; 2055 | } 2056 | 2057 | if ( History$$1 ) AbstractHistory.__proto__ = History$$1; 2058 | AbstractHistory.prototype = Object.create( History$$1 && History$$1.prototype ); 2059 | AbstractHistory.prototype.constructor = AbstractHistory; 2060 | 2061 | AbstractHistory.prototype.push = function push (location, onComplete, onAbort) { 2062 | var this$1 = this; 2063 | 2064 | this.transitionTo(location, function (route) { 2065 | this$1.stack = this$1.stack.slice(0, this$1.index + 1).concat(route); 2066 | this$1.index++; 2067 | onComplete && onComplete(route); 2068 | }, onAbort); 2069 | }; 2070 | 2071 | AbstractHistory.prototype.replace = function replace (location, onComplete, onAbort) { 2072 | var this$1 = this; 2073 | 2074 | this.transitionTo(location, function (route) { 2075 | this$1.stack = this$1.stack.slice(0, this$1.index).concat(route); 2076 | onComplete && onComplete(route); 2077 | }, onAbort); 2078 | }; 2079 | 2080 | AbstractHistory.prototype.go = function go (n) { 2081 | var this$1 = this; 2082 | 2083 | var targetIndex = this.index + n; 2084 | if (targetIndex < 0 || targetIndex >= this.stack.length) { 2085 | return 2086 | } 2087 | var route = this.stack[targetIndex]; 2088 | this.confirmTransition(route, function () { 2089 | this$1.index = targetIndex; 2090 | this$1.updateRoute(route); 2091 | }); 2092 | }; 2093 | 2094 | AbstractHistory.prototype.getCurrentLocation = function getCurrentLocation () { 2095 | var current = this.stack[this.stack.length - 1]; 2096 | return current ? current.fullPath : '/' 2097 | }; 2098 | 2099 | AbstractHistory.prototype.ensureURL = function ensureURL () { 2100 | // noop 2101 | }; 2102 | 2103 | return AbstractHistory; 2104 | }(History)); 2105 | 2106 | /* */ 2107 | 2108 | var VueRouter = function VueRouter (options) { 2109 | if ( options === void 0 ) options = {}; 2110 | 2111 | this.app = null; 2112 | this.apps = []; 2113 | this.options = options; 2114 | this.beforeHooks = []; 2115 | this.afterHooks = []; 2116 | this.matcher = createMatcher(options.routes || []); 2117 | 2118 | var mode = options.mode || 'hash'; 2119 | this.fallback = mode === 'history' && !supportsPushState; 2120 | if (this.fallback) { 2121 | mode = 'hash'; 2122 | } 2123 | if (!inBrowser) { 2124 | mode = 'abstract'; 2125 | } 2126 | this.mode = mode; 2127 | 2128 | switch (mode) { 2129 | case 'history': 2130 | this.history = new HTML5History(this, options.base); 2131 | break 2132 | case 'hash': 2133 | this.history = new HashHistory(this, options.base, this.fallback); 2134 | break 2135 | case 'abstract': 2136 | this.history = new AbstractHistory(this, options.base); 2137 | break 2138 | default: 2139 | { 2140 | assert(false, ("invalid mode: " + mode)); 2141 | } 2142 | } 2143 | }; 2144 | 2145 | var prototypeAccessors = { currentRoute: {} }; 2146 | 2147 | VueRouter.prototype.match = function match ( 2148 | raw, 2149 | current, 2150 | redirectedFrom 2151 | ) { 2152 | return this.matcher.match(raw, current, redirectedFrom) 2153 | }; 2154 | 2155 | prototypeAccessors.currentRoute.get = function () { 2156 | return this.history && this.history.current 2157 | }; 2158 | 2159 | VueRouter.prototype.init = function init (app /* Vue component instance */) { 2160 | var this$1 = this; 2161 | 2162 | "development" !== 'production' && assert( 2163 | install.installed, 2164 | "not installed. Make sure to call `Vue.use(VueRouter)` " + 2165 | "before creating root instance." 2166 | ); 2167 | 2168 | this.apps.push(app); 2169 | 2170 | // main app already initialized. 2171 | if (this.app) { 2172 | return 2173 | } 2174 | 2175 | this.app = app; 2176 | 2177 | var history = this.history; 2178 | 2179 | if (history instanceof HTML5History) { 2180 | history.transitionTo(history.getCurrentLocation()); 2181 | } else if (history instanceof HashHistory) { 2182 | var setupHashListener = function () { 2183 | history.setupListeners(); 2184 | }; 2185 | history.transitionTo( 2186 | history.getCurrentLocation(), 2187 | setupHashListener, 2188 | setupHashListener 2189 | ); 2190 | } 2191 | 2192 | history.listen(function (route) { 2193 | this$1.apps.forEach(function (app) { 2194 | app._route = route; 2195 | }); 2196 | }); 2197 | }; 2198 | 2199 | VueRouter.prototype.beforeEach = function beforeEach (fn) { 2200 | this.beforeHooks.push(fn); 2201 | }; 2202 | 2203 | VueRouter.prototype.afterEach = function afterEach (fn) { 2204 | this.afterHooks.push(fn); 2205 | }; 2206 | 2207 | VueRouter.prototype.onReady = function onReady (cb) { 2208 | this.history.onReady(cb); 2209 | }; 2210 | 2211 | VueRouter.prototype.push = function push (location, onComplete, onAbort) { 2212 | this.history.push(location, onComplete, onAbort); 2213 | }; 2214 | 2215 | VueRouter.prototype.replace = function replace (location, onComplete, onAbort) { 2216 | this.history.replace(location, onComplete, onAbort); 2217 | }; 2218 | 2219 | VueRouter.prototype.go = function go (n) { 2220 | this.history.go(n); 2221 | }; 2222 | 2223 | VueRouter.prototype.back = function back () { 2224 | this.go(-1); 2225 | }; 2226 | 2227 | VueRouter.prototype.forward = function forward () { 2228 | this.go(1); 2229 | }; 2230 | 2231 | VueRouter.prototype.getMatchedComponents = function getMatchedComponents (to) { 2232 | var route = to 2233 | ? this.resolve(to).route 2234 | : this.currentRoute; 2235 | if (!route) { 2236 | return [] 2237 | } 2238 | return [].concat.apply([], route.matched.map(function (m) { 2239 | return Object.keys(m.components).map(function (key) { 2240 | return m.components[key] 2241 | }) 2242 | })) 2243 | }; 2244 | 2245 | VueRouter.prototype.resolve = function resolve ( 2246 | to, 2247 | current, 2248 | append 2249 | ) { 2250 | var location = normalizeLocation(to, current || this.history.current, append); 2251 | var route = this.match(location, current); 2252 | var fullPath = route.redirectedFrom || route.fullPath; 2253 | var base = this.history.base; 2254 | var href = createHref(base, fullPath, this.mode); 2255 | return { 2256 | location: location, 2257 | route: route, 2258 | href: href, 2259 | // for backwards compat 2260 | normalizedTo: location, 2261 | resolved: route 2262 | } 2263 | }; 2264 | 2265 | VueRouter.prototype.addRoutes = function addRoutes (routes) { 2266 | this.matcher.addRoutes(routes); 2267 | if (this.history.current !== START) { 2268 | this.history.transitionTo(this.history.getCurrentLocation()); 2269 | } 2270 | }; 2271 | 2272 | Object.defineProperties( VueRouter.prototype, prototypeAccessors ); 2273 | 2274 | function createHref (base, fullPath, mode) { 2275 | var path = mode === 'hash' ? '#' + fullPath : fullPath; 2276 | return base ? cleanPath(base + '/' + path) : path 2277 | } 2278 | 2279 | VueRouter.install = install; 2280 | VueRouter.version = '2.2.0'; 2281 | 2282 | if (inBrowser && window.Vue) { 2283 | window.Vue.use(VueRouter); 2284 | } 2285 | 2286 | return VueRouter; 2287 | 2288 | }))); --------------------------------------------------------------------------------