commit 452e55b192fee71e90d8789c087670ace736d3c9
Author: xsf <416175716@qq.com>
Date: Thu Aug 18 17:47:12 2016 +0800
20160818/17:47
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8883194
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+node_modules/
+build/
+d.html
+npm-debug.log
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..97626ba
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..66f26e7
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vue-vueRouter-webpack.iml b/.idea/vue-vueRouter-webpack.iml
new file mode 100644
index 0000000..d7a18b1
--- /dev/null
+++ b/.idea/vue-vueRouter-webpack.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..7d5738c
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,669 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $PROJECT_DIR$
+ true
+
+ bdd
+
+ DIRECTORY
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1471498492040
+
+ 1471498492040
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Vue教程.md b/Vue教程.md
new file mode 100644
index 0000000..ba72f4b
--- /dev/null
+++ b/Vue教程.md
@@ -0,0 +1,65 @@
+#Vue教程
+
+[细节与最佳实践](http://vuejs.org/guide/best-practices.html)
+
+[Vue1.0.x文档](http://vuejs.org/)
+
+[Vue1.0.x绑定语法参考](https://github.com/vuejs/vue/issues/1325)
+
+[每次更新的变化](https://github.com/vuejs/vue/releases)
+
+与webpack 一起使用所需插件
+
+[vue-loader-example](https://github.com/vuejs/vue-loader-example)
+
+[vue-html-loader](https://github.com/vuejs/vue-html-loader)
+
+####文章
+`尤小右`
+
+[Vue.js:轻量高效的前端组件化方案](http://www.csdn.net/article/1970-01-01/2825439)
+
+`勾三股四`
+
+[Vue + webpack 项目实践](http://jiongks.name/blog/just-vue/)
+
+[Vue.js 源码学习笔记](http://jiongks.name/blog/vue-code-review/)
+
+`稀土掘金`
+
+[Vue 组件化开发实践](http://ftandy.github.io/2015/09/05/vue/)
+
+`Randy`
+
+[Vue.js 和 Webpack(一)为什么使用Vue](http://djyde.github.io/2015/08/29/vuejs-and-webpack-1.html)
+
+[Vue.js 和 Webpack(二)使用webpack](http://djyde.github.io/2015/08/30/vuejs-and-webpack-2.html)
+
+[Vue.js 和 Webpack(三)Vue.js + Webpack](http://djyde.github.io/2015/08/31/vuejs-and-webpack-3.html)
+
+#webpack教程
+[learn-webpack](http://vingojw.github.io/2015/08/19/learn-webpack/)
+
+#Vue-router教程
+[中文文档](http://vuejs.github.io/vue-router/zh-cn/index.html) - [英文文档](http://vuejs.github.io/vue-router/en/index.html)
+[学习笔记](https://github.com/vingojw/learn-vue-router)
+
+#技术交流
+
+[Vue技术论坛](http://forum.vuejs.org/)
+
+[Vue的聊天室,很多人在里面讨论并解决问题](https://gitter.im/vuejs/vue)
+
+#demo
+
+[qingcheng](https://github.com/zerqu/qingcheng)
+
+[vue-strap 用vue实现bootstrap](https://github.com/yuche/vue-strap)
+
+[vue-mui](https://github.com/mennghao/vue-mui)
+
+[通过学习(copy)以上两个demo,使用 Vue1.0 + VueRouter + webpack](https://github.com/vingojw/vue-vueRoute-webpack)
+
+[Chat by Vue + Webpack](https://github.com/Coffcer/vue-chat)
+
+[用Vue实现的拖拽效果](http://jsfiddle.net/lain8dono/mrnyf79e/)
\ No newline at end of file
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..f0ded4c
--- /dev/null
+++ b/index.html
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+ 首页
+
+
+
+
+
+
+
diff --git a/index.tpl b/index.tpl
new file mode 100644
index 0000000..bb7ce37
--- /dev/null
+++ b/index.tpl
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..b5445bd
--- /dev/null
+++ b/package.json
@@ -0,0 +1,46 @@
+{
+ "name": "learn-webpack",
+ "version": "1.0.0",
+ "main": "index.js",
+ "dependencies": {
+ "extract-text-webpack-plugin": "^0.8.2"
+ },
+ "devDependencies": {
+ "babel-core": "^6.3.17",
+ "babel-loader": "^6.2.0",
+ "babel-plugin-transform-runtime": "^6.3.13",
+ "babel-preset-es2015": "^6.3.13",
+ "babel-runtime": "^5.8.34",
+ "css-loader": "^0.23.0",
+ "cssnext-loader": "^1.0.1",
+ "fastclick": "^1.0.6",
+ "file-loader": "^0.8.4",
+ "hammerjs": "^2.0.6",
+ "html-loader": "^0.3.0",
+ "html-webpack-plugin": "^1.6.2",
+ "jshint-loader": "^0.8.3",
+ "style-loader": "^0.13.0",
+ "swiper": "^3.2.0",
+ "url-loader": "^0.5.6",
+ "vue": "^1.0.20",
+ "vue-hot-reload-api": "^1.2.2",
+ "vue-html-loader": "^1.1.0",
+ "vue-loader": "^8.2.0",
+ "vue-router": "^0.7.11",
+ "vue-style-loader": "^1.0.0",
+ "webpack": "^1.12.9",
+ "webpack-dev-server": "^1.14.0",
+ "webpack-zepto": "0.0.1"
+ },
+ "scripts": {
+ "mb": "export PRODUCTION=1 && webpack --progress --hide-modules",
+ "wb": "set PRODUCTION=1 && webpack --progress --hide-modules",
+ "start": "webpack-dev-server --progress --profile --colors --inline ",
+ "port": "webpack-dev-server --progress --colors --inline --port 9090 ",
+ "hot": "webpack-dev-server --progress --colors --inline --hot",
+ "cp": "cp -r index.html ./build/ d:/wamp/www/vue",
+ "ip": "webpack-dev-server --progress --colors --hot --host=0.0.0.0 --port 9000"
+ },
+ "author": "",
+ "license": "ISC"
+}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..4160072
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,58 @@
+## Setup
+``` bash
+npm install
+npm start
+```
+访问 localhost:8080
+
+如果想在手机上查看
+
+```
+npm run ip
+```
+访问 你本地的ip:9000
+
+## 版本控制,打包压缩
+MAC
+
+```
+npm run mb
+```
+
+windows
+
+```
+npm run wb
+```
+
+## 目录结构
+
+│ .gitignore # 忽略无需git控制的文件 比如 node_modules
+│ package.json # 项目配置
+│ readme.md # 项目说明
+│ index.html # 首页
+│ index.tpl # 首页模板 在发布的时候 执行 PRODUCTION=1 webpack 会生成一个d.html并注入脚本,样式,达到版本控制的目的
+│ webpack.config.js # webpack 配置文件
+│
+├─node_modules
+└─src
+ │ app.js # 启动配置,配置路由,过滤器
+ │ app.vue # 主vue
+ │ filters.js # 过滤器
+ │ routers.js # 路由
+ │
+ ├─components # 组件
+ │ my-component.vue
+ │
+ ├─css # 公用样式
+ │ common.css
+ │
+ └─views # 页面
+ about.vue
+ home.vue
+ not-found.vue
+
+
+##学习参考:
+待续
+
diff --git a/src/app.js b/src/app.js
new file mode 100644
index 0000000..c8632c0
--- /dev/null
+++ b/src/app.js
@@ -0,0 +1,33 @@
+
+require('./css/common.css');//加载公共样式
+require('./css/animate.css');//加载公共样式
+
+var Vue = require('vue');
+var VueRouter = require('vue-router');
+var fastclick = require('fastclick');
+fastclick.attach(document.body);
+
+// register filters 自定义过滤器 金额格式化,
+var filters = require('./filters');
+
+Object.keys(filters).forEach(function(k) {
+ Vue.filter(k, filters[k]);
+});
+
+var App = Vue.extend(require('./app.vue'));
+ Vue.use(VueRouter);
+
+var router = new VueRouter(
+ {
+ hashbang: true, //为true的时候 example.com/#!/foo/bar , false的时候 example.com/#/foo/bar
+ //abstract:true, //地址栏不会有变化
+ //以下设置需要服务端设置
+ //history: false, //当使用 HTML5 history 模式时,服务器需要被正确配置 以防用户在直接访问链接时会遇到404页面。
+ //saveScrollPosition: false
+ linkActiveClass:'custom-active-class' //全局设置连接匹配时的类名 参考http://vuejs.github.io/vue-router/en/link.html
+ }
+);
+
+require('./routers')(router);
+
+router.start(App,'#app');
\ No newline at end of file
diff --git a/src/app.vue b/src/app.vue
new file mode 100644
index 0000000..159d606
--- /dev/null
+++ b/src/app.vue
@@ -0,0 +1,73 @@
+
+
+
+
+
+
diff --git a/src/components/select.vue b/src/components/select.vue
new file mode 100644
index 0000000..0a92f07
--- /dev/null
+++ b/src/components/select.vue
@@ -0,0 +1,109 @@
+
+
+
+
+
default title
+
+
{{chooseval}}
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/css/animate.css b/src/css/animate.css
new file mode 100644
index 0000000..cbe0be1
--- /dev/null
+++ b/src/css/animate.css
@@ -0,0 +1,165 @@
+/*所有的动画*/
+ .slideleft-enter {
+ animation:slideleft-in .3s;
+ }
+ .slideleft-leave {
+ animation:slideleft-out .3s;
+ }
+ .slideright-enter {
+ animation:slideright-in .3s;
+ }
+ .slideright-leave {
+ animation:slideright-out .3s;
+ }
+ .slidetop-enter {
+ animation:slidetop-in .3s;
+ }
+ .slidetop-leave {
+ animation:slidetop-out .3s;
+ }
+ .slidebottom-enter {
+ animation:slidebottom-in .3s;
+ }
+ .slidebottom-leave {
+ animation:slidebottom-out .3s;
+ }
+ @keyframes slideleft-in {
+ 0% {
+ transform: translateX(-100%);
+ opacity: 0;
+ }
+ 100% {
+ transform: translateX(0);
+ opacity: 1;
+ }
+ }
+
+ @keyframes slideleft-out {
+ 0% {
+ transform: translateX(0);
+ opacity: 1;
+ }
+ 100% {
+ transform: translateX(-100%);
+ opacity: 0;
+ }
+ }
+
+ @keyframes slideright-in {
+ 0% {
+ transform: translateX(100%);
+ opacity: 0;
+ }
+ 100% {
+ transform: translateX(0);
+ opacity: 1;
+ }
+ }
+
+ @keyframes slideright-out {
+ 0% {
+ transform: translateX(0);
+ opacity: 1;
+ }
+ 100% {
+ transform: translateX(100%);
+ opacity: 0;
+ }
+ }
+ @keyframes slidetop-in {
+ 0% {
+ transform: translateY(-100%);
+ opacity: 0;
+ }
+ 100% {
+ transform: translateX(0);
+ opacity: 1;
+ }
+ }
+
+ @keyframes slidetop-out {
+ 0% {
+ transform: translateX(0);
+ opacity: 1;
+ }
+ 100% {
+ transform: translateY(-100%);
+ opacity: 0;
+ }
+ }
+ @keyframes slidebottom-in {
+ 0% {
+ transform: translateY(100%);
+ opacity: 0;
+ }
+ 100% {
+ transform: translateX(0);
+ opacity: 1;
+ }
+ }
+ @keyframes slidebottom-out {
+ 0% {
+ transform: translateX(0);
+ opacity: 1;
+ }
+ 100% {
+ transform: translateY(100%);
+ opacity: 0;
+ }
+ }
+
+
+/*切换效果 -- 渐隐*/
+.fadein-enter{
+ animation:fadein-in 0.3s ease;
+}
+.fadein-leave{
+ animation:fadein-out 0.3s ease;
+}
+
+/*切换效果 -- 从右渐入*/
+.fadeInRight-enter {
+ animation:fadeInRight-in 0.3s ease;
+}
+.fadeInRight-leave{
+ animation:fadeInRight-out 0.3s ease;
+}
+
+@keyframes fadein-in {
+ 0% {
+ opacity: 0;
+ }
+ 100% {
+ opacity: 1;
+ }
+}
+@keyframes fadein-out {
+ 0% {
+ opacity: 1;
+ }
+ 100% {
+ opacity: 0;
+ }
+}
+@keyframes fadeInRight-in {
+ 0% {
+ opacity: 0;
+ transform: translate3d(2000px,0,0)
+ }
+
+ 100% {
+ opacity: 1;
+ transform: none
+ }
+}
+@keyframes fadeInRight-out {
+ 0% {
+ opacity: 1;
+ transform: none
+ }
+
+ 100% {
+ opacity: 0;
+ transform: translate3d(-2000px,0,0)
+ }
+}
diff --git a/src/css/b.css b/src/css/b.css
new file mode 100644
index 0000000..a4e9078
--- /dev/null
+++ b/src/css/b.css
@@ -0,0 +1,3 @@
+.bbb{
+ background:black;
+}
\ No newline at end of file
diff --git a/src/css/common.css b/src/css/common.css
new file mode 100644
index 0000000..c1869ca
--- /dev/null
+++ b/src/css/common.css
@@ -0,0 +1,81 @@
+@charset "utf-8";
+@charset "utf-8";
+
+/*清零*/
+body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td { margin:0; padding:0;}
+fieldset,img { border:0;}
+ol,ul { list-style:none; }
+h1,h2,h3,h4,h5,h6,button,input,select,textarea { font-size:100%;
+ font-weight: normal; }
+button::-moz-focus-inner,input::-moz-focus-inner{ padding:0; border:0; }
+table{ border-collapse: collapse; border-spacing: 0; }
+i, cite, em, var, dfn, address { font-style: normal; }
+body{ font:14px "方正兰亭细黑简体","微软雅黑","宋体",Arial;}
+a{ text-decoration:none; outline: none;}
+a:hover{ text-decoration: none; }
+a:active, a:focus{ outline:none; }
+b{ font-weight: normal; }
+input ,button{ border: none; outline: none;}
+input:not([type="radio"]){appearance:none;-webkit-appearance:none;-o-appearance:none;-moz-appearance:none;}
+button:active{
+ transform:scale(0.9);
+ -webkit-transform: scale(0.9);
+ -moz-transform: scale(0.9);
+ -ms-transform: scale(0.9);
+ -o-transform: scale(0.9);
+}
+textarea{
+ appearance: none;
+ -webkit-appearance: none;
+ -moz-appearance: none;
+ -o-appearance: none;
+ resize: none;
+}
+input{
+ border-radius: 0;
+}
+
+*{
+ box-sizing: border-box;
+}
+
+a{
+ color: #232323;
+}
+button{
+ background: none;
+}
+
+
+@font-face {
+ font-family: "iconfont";
+ src: require('iconfont.woff') format('woff'),
+ require('iconfont.ttf') format('truetype'),
+ require('iconfont.svg#iconfont') format('svg');
+}
+
+.iconfont {
+ font-family:"iconfont" !important;
+ font-style:normal;
+ -webkit-font-smoothing: antialiased;
+ -webkit-text-stroke-width: 0.2px;
+ -moz-osx-font-smoothing: grayscale;
+}
+
+[v-cloak] {
+ display: none;
+}
+
+.col2{
+ width: 50%;
+}
+.col3{
+ width: 33.33%;
+}
+.col4{
+ width: 25%;
+}
+.col6{
+ width: 16.66%;
+}
+
diff --git a/src/css/testInAbout.css b/src/css/testInAbout.css
new file mode 100644
index 0000000..71dc434
--- /dev/null
+++ b/src/css/testInAbout.css
@@ -0,0 +1,19 @@
+h2{
+ font-size: 28px;
+ text-align: center;
+}
+span{
+ font-size: 15px;
+ color: red;
+}
+p{
+ font-size: 14px;
+ text-align: center;
+}
+.about img{
+ width: 180px;
+ margin-top: 70px;
+}
+.about{
+ padding-top: 15px;
+}
\ No newline at end of file
diff --git a/src/filters.js b/src/filters.js
new file mode 100644
index 0000000..e4182bc
--- /dev/null
+++ b/src/filters.js
@@ -0,0 +1,78 @@
+
+
+function timeago(time) {
+ time = new Date(time);
+ var delta = parseInt((new Date() - time) / 1000, 10);
+ if (delta <= 0) return 'just now';
+
+ var minutes = delta / 60;
+ if (minutes < 1) return 'less than a minute ago';
+ if (minutes < 2) return 'about a minute ago';
+
+ var hours = minutes / 60;
+ if (hours < 1) return parseInt(minutes, 10) + ' minutes ago';
+ if (hours < 1.5) return 'about an hour ago';
+
+ var days = hours / 24;
+ if (days < 1) return Math.round(hours) + ' hours ago';
+ if (days < 7) return parseInt(days, 10) + ' days ago';
+
+ var month = time.getMonth();
+ if (month < 10) month = '0' + month;
+ var date = time.getDate();
+ if (date < 10) date = '0' + date;
+ return [time.getFullYear(), month, date].join('-');
+}
+
+
+function urlize(text) {
+ if (!text) return '';
+ var pattern = /https?:\/\/[^\s<]+[^<.,:;"')\]\s]/g;
+ return text.replace(pattern, function(u) {
+ var t = u.replace('http://', '');
+ return '' + t + ' ';
+ });
+}
+
+//获取图片地址,如果地址带有 http://那么就认为是绝对地址,然后直接返回
+function imgUrl(url){
+ if(url.match(/http:\/\//)){
+ return url;
+ }
+
+ //全站统一配置,页面首先会引用
+ if(window.abp){
+ return window.abp.imageDomain + url;
+ }
+ var testUrl = 'http://img.yaomaiche.com'; //此url到时候走配置
+
+ if(this.isTest){
+ testUrl = 'http://img.test.yaomaiche.com';
+ }
+ return testUrl + url;
+}
+
+
+//显示价格
+function price(value,currency){
+var digitsRE = /(\d{3})(?=\d)/g
+ value = parseFloat(value)
+ if (!isFinite(value) || (!value && value !== 0)) return ''
+ currency = currency != null ? currency : '¥'
+ var stringified = Math.abs(value).toFixed(2)
+ var _int = stringified.slice(0, -3)
+ var i = _int.length % 3
+ var head = i > 0
+ ? (_int.slice(0, i) + (_int.length > 3 ? ',' : ''))
+ : ''
+ var _float = stringified.slice(-3)
+ var sign = value < 0 ? '-' : ''
+ return currency + sign + head +
+ _int.slice(i).replace(digitsRE, '$1,') +
+ _float
+}
+
+exports.imgUrl = imgUrl;
+exports.price = price;
+exports.timeago = timeago;
+exports.urlize = urlize;
diff --git a/src/images/logo.png b/src/images/logo.png
new file mode 100644
index 0000000..8bbf984
Binary files /dev/null and b/src/images/logo.png differ
diff --git a/src/routers.js b/src/routers.js
new file mode 100644
index 0000000..242245b
--- /dev/null
+++ b/src/routers.js
@@ -0,0 +1,76 @@
+module.exports = function(router){
+ router.map({
+ '/':{
+ name:'index',
+ component: require('./views/index.vue')
+ },
+ '/news':{
+ name:'news',
+ component: function(reslove){
+ return require(['./views/news.vue'],reslove)
+ }
+ },
+ '/search': {
+ name:'search',
+ component: require('./views/search.vue')
+ },
+ '/about/:viewId': {
+ name:'about',
+ component: require('./views/about.vue'),
+ auth: true // 此页面需要用户登录
+ },
+ '/my_views': {
+ name:'my_views',
+ component: require('./views/my_views.vue')
+ },
+ });
+
+ window.routeList=[];
+
+ router.beforeEach(function(transition){
+ console.log(11111);
+ console.log('before---------------');
+ //可以通过在路由中的自定义字段来验证用户是否需要登陆
+ // if(transition.to.auth){
+ // console.log('通过配置路由中自定义的字段验证是否需要登陆');
+ // }
+
+ // //如果是中止,这里可以判断用户登录
+ // //if(transition.to.path === '/forbidden'){
+ if(transition.to.name == 'forbidden'){
+ router.app.authenticating = true
+ setTimeout(function(){
+ router.app.authenticating = false
+ alert('此路由在全局中设置为中止');
+ transition.abort();
+ },1500);
+ }
+
+ if(routeList.length > 1 && transition.to.name==routeList[routeList.length-2]['name']){
+ router.app.effect='back';
+ routeList.splice(routeList.length-1,1);
+ console.log(routeList);
+ } else {
+ router.app.effect='fade';
+ routeList.push({
+ name : transition.to.name,
+ path : transition.to.path,
+ query : transition.to.query,
+ params : transition.to.params,
+ timer: +new Date
+ });
+ }
+
+ setTimeout(function(){
+ transition.next();
+ },00);
+ });
+
+ //可以记录访问路径
+ router.afterEach(function(transition){
+ console.log('-----------------after');
+ for (var i = 0; i < routeList.length; i++) {
+ console.log(routeList[i].name);
+ };
+ });
+}
\ No newline at end of file
diff --git a/src/views/about.vue b/src/views/about.vue
new file mode 100644
index 0000000..cc6a800
--- /dev/null
+++ b/src/views/about.vue
@@ -0,0 +1,27 @@
+
+
+
you're in {{title}} page!
+
{{content}}
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/views/home.vue b/src/views/home.vue
new file mode 100644
index 0000000..52d1ce4
--- /dev/null
+++ b/src/views/home.vue
@@ -0,0 +1,21 @@
+
+
+ Welcome to Home router page!
+
+
+
+
\ No newline at end of file
diff --git a/src/views/index.vue b/src/views/index.vue
new file mode 100644
index 0000000..8a334e2
--- /dev/null
+++ b/src/views/index.vue
@@ -0,0 +1,106 @@
+
+
+
+
vue-router 介绍:
+
点击这里
+
+
+
+
\ No newline at end of file
diff --git a/src/views/my_views.vue b/src/views/my_views.vue
new file mode 100644
index 0000000..180431d
--- /dev/null
+++ b/src/views/my_views.vue
@@ -0,0 +1,98 @@
+
+
+ 啥玩意儿?my_views.vue
+
+
+
\ No newline at end of file
diff --git a/src/views/news.vue b/src/views/news.vue
new file mode 100644
index 0000000..e888e69
--- /dev/null
+++ b/src/views/news.vue
@@ -0,0 +1,38 @@
+
+
+
+ 教你使用component!
+
+
+ 下面这个来自component
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/views/search.vue b/src/views/search.vue
new file mode 100644
index 0000000..b6ebd59
--- /dev/null
+++ b/src/views/search.vue
@@ -0,0 +1,17 @@
+
+
+
+
+ Welcome to search router page!
+
+
+
+
\ No newline at end of file
diff --git a/vueComponent.sublime-snippet b/vueComponent.sublime-snippet
new file mode 100644
index 0000000..b72ee12
--- /dev/null
+++ b/vueComponent.sublime-snippet
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+]]>
+
+ vueComponent
+
diff --git a/webpack.config.js b/webpack.config.js
new file mode 100644
index 0000000..37f2601
--- /dev/null
+++ b/webpack.config.js
@@ -0,0 +1,135 @@
+//先清空 n-build 文件夹下的文件
+var fs = require('fs'),buildPath='./build/';
+var folder_exists = fs.existsSync(buildPath);
+if(folder_exists == true)
+{
+ var dirList = fs.readdirSync(buildPath);
+ dirList.forEach(function(fileName)
+ {
+ fs.unlinkSync(buildPath + fileName);
+ });
+ console.log("clearing " + buildPath);
+};
+
+//readfile
+//先把index.html里面关于style和js的hash值都删除掉,避免在使用 npm run dev 的时候,路径还是压缩后的路劲
+fs.readFile("index.html",'utf-8',function(err,data){
+ if(err){
+ console.log("error");
+ }else{
+ //将index.html里面的hash值清除掉
+ var devhtml = data.replace(/((?:href|src)="[^"]+\.)(\w{20}\.)(js|css)/g, '$1$3');
+ fs.writeFileSync('index.html', devhtml);
+ }
+});
+
+var webpack = require('webpack');
+
+//var vue = require("vue-loader");
+
+
+//混淆压缩
+var uglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
+
+//检测重用模块
+var CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin;
+
+//独立样式文件
+var ExtractTextPlugin = require("extract-text-webpack-plugin");
+
+
+
+// 在命令行 输入 “PRODUCTION=1 webpack --progress” 就会打包压缩,并且注入md5戳 到 index.html里面
+var production = process.env.PRODUCTION;
+
+var plugins = [
+ //会将所有的样式文件打包成一个单独的style.css
+ new ExtractTextPlugin( production ? "style.[hash].css" : "style.css" , {
+ disable: false//,
+ //allChunks: true //所有独立样式打包成一个css文件
+ }),
+ //new ExtractTextPlugin("[name].css" )
+ //自动分析重用的模块并且打包成单独的文件
+ new CommonsChunkPlugin(production ? "vendor.[hash].js" : "vendor.js" ),
+ function(){
+ return this.plugin('done', function(stats) {
+ var content;
+ //这里可以拿到hash值 参考:http://webpack.github.io/docs/long-term-caching.html
+ content = JSON.stringify(stats.toJson().assetsByChunkName, null, 2);
+ console.log('版本是:'+JSON.stringify(stats.toJson().hash));
+ //return fs.writeFileSync('build/assets.json', content);
+ });
+ }
+];
+
+//发布编译时,压缩,版本控制
+if (process.env.PRODUCTION) {
+ //压缩
+ plugins.push(new webpack.optimize.UglifyJsPlugin({compress: {warnings: false } }));
+}
+
+/*
+ 版本控制
+ package.json中的
+ "html-webpack-plugin": "^1.6.2",
+ 模块是把生成的带有md5戳的文件,插入到index.html中。
+ 通过index.tpl模板,生成 index.html
+ */
+var HtmlWebpackPlugin = require("html-webpack-plugin");
+//HtmlWebpackPlugin文档 https://www.npmjs.com/package/html-webpack-plugin
+//https://github.com/ampedandwired/html-webpack-plugin/issues/52
+plugins.push( new HtmlWebpackPlugin({
+ filename:'../index.html',//会生成index.html在根目录下,并注入脚本
+ template:'index.tpl',
+ inject:true //此参数必须加上,不加不注入
+}));
+
+
+module.exports = {
+ entry: ["./src/app.js"],
+ output: {
+ path: "./build",
+ /*
+ publicPath路径就是你发布之后的路径,
+ 比如你想发布到你站点的/util/vue/build 目录下, 那么设置
+ publicPath: "/util/vue/build/",
+ 此字段配置如果不正确,发布后资源定位不对,比如:css里面的精灵图路径错误
+ */
+ publicPath: "/build/",
+ filename: production ? "build.[hash].js" : "build.js"//"build.[hash].js"//[hash]MD5戳 解决html的资源的定位可以使用 webpack提供的HtmlWebpackPlugin插件来解决这个问题 见:http://segmentfault.com/a/1190000003499526 资源路径切换
+ },
+ module: {
+ preLoaders:[
+ // {
+ // //代码检查
+ // test:/\.js$/,exclude:/node_modules/,loader:'jshint-loader'
+ // }
+ ],
+ loaders: [
+ // 加载vue组件,并将css全部整合到一个style.css里面
+ // 但是使用这种方式后 原先可以在vue组件中 在style里面加入 scoped 就不能用了,
+ // 好处是使用了cssnext,那么样式按照标准的来写就行了,会自动生成兼容代码 http://cssnext.io/playground/
+ {
+ test: /\.vue$/,
+ loader: 'vue'
+ },
+ {test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader?sourceMap!cssnext-loader")},
+ {test: /\.(png|jpg)$/, loader: 'url-loader?limit=8192'}, // 内联 base64 URLs, 限定 <=8k 的图片, 其他的用 URL
+ {test: /\.woff$/, loader: "url?limit=10000&minetype=application/font-woff"},
+ {test: /\.ttf$/, loader: "file"},
+ {test: /\.eot$/, loader: "file"},
+ {test: /\.svg$/, loader: "file"}
+ ]
+ },
+ vue:{
+ css:ExtractTextPlugin.extract("style-loader", "css-loader?sourceMap!cssnext-loader")
+ },
+ plugins : plugins,
+ devtool: 'source-map'//,
+ // resolve: {
+ // // 现在可以写 require('file') 代替 require('file.coffee')
+ // extensions: ['', '.js', '.json', '.coffee','vue']
+ // }
+};
+
+
diff --git a/约定.md b/约定.md
new file mode 100644
index 0000000..bf3f796
--- /dev/null
+++ b/约定.md
@@ -0,0 +1,144 @@
+
+
+#### 使用具名路径
+
+```
+User
+```
+
+#### 组件传值的时候单个单词小写,如果有多个单词用"-"连接 [API说明](http://rc.vuejs.org/guide/components.html#camelCase_vs-_kebab-case)
+
+```
+
+
+```
+然后在组件props中用驼峰的方式访问['mutilCheck']。
+
+#### 组件传值得时候尽量不要使用表达式,可以在computed中定义
+比如:
+
+```
+
+```
+修改为
+```
+
+```
+然后定义computed
+
+```
+ ...
+ computed:{
+ singleCheck:function(){
+ return false;
+ }
+ },
+ ...
+```
+
+#### 在绑定属性的时候
+```
+
+
+
+ 此处的 transition="transiton" 代表的是 transition 这个类名
+```
+而如果前面加个`:`则代表的是动态属性,: 是 v-bind的简写 参考 [Vue1.0.0绑定语法参考](https://github.com/vuejs/vue/issues/1325)
+
+```
+
+```
+
+#### 绑定属性用双引号
+
+
+#### 关于 vueComponent.sublime-snippet 文件
+```
+功能:sublime中编写vue组件的片段提示
+使用:
+ sublime中 菜单栏 - >Preferences - > 浏览插件
+ 将文件复制到 User目录下
+ 项目中新建 `组件名字.vue` 文件
+ ctrl+shift+p 输入 vuecomponent 回车
+```
+
+
+#### 在vue组件 template 中不能出现 `<` 字符, 如果有此字符,那么在使用webpack.optimize.UglifyJsPlugin压缩的时候,编译会报错
+
+#### DOM属性定义用""包起来,否则不正确的字符可能会导致在 使用webpack.optimize.UglifyJsPlugin压缩的时候,控制台卡死。
+
+#### vue文件的,template模版中,注释的html里面如果有img标签,相关资源也会被打包。
+
+```
+
+
+```
+
+#### 在data属性里面不要定义以下划线开头的字段。
+
+```
+data:{
+ _k:'v' // this._k 获取不到
+}
+```
+
+#### vue-router路由配置的时候,不要写下划线
+
+```
+ '/loan':{
+ name:'loan',
+ component: require('./views/loan.vue')
+ },
+ '/loan_old':{
+ name:'xxx',
+ component: require('./views/loan_old.vue')
+ },
+ 下面的会覆盖上面的,原来本应该跳转到loan的可能现在都跳到了loan_old
+```
+
+#### 关于版本控制
+参考:
+[http://webpack.github.io/docs/long-term-caching.html](http://webpack.github.io/docs/long-term-caching.html)
+
+[https://github.com/teambition/coffee-webpack-starter/blob/92082085d96f6c5003711e042da38bfa140d8dd6/webpack.min.coffee#L21](https://github.com/teambition/coffee-webpack-starter/blob/92082085d96f6c5003711e042da38bfa140d8dd6/webpack.min.coffee#L21)
+
+
+```
+ plugins: [
+ new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.[chunkhash:8].js'),
+ new webpack.optimize.UglifyJsPlugin({sourceMap: false}),
+ new ExtractTextPlugin("style.[chunkhash:8].css"),
+ function() {
+ return this.plugin('done', function(stats) {
+ var content;
+ content = JSON.stringify(stats.toJson().assetsByChunkName, null, 2);
+ return fs.writeFileSync('build/assets.json', content);
+ });
+ }
+ ]
+```
+
+#### 禁止在层上滑动(比如:背景层,不想让用户滚动)
+```
+@touchstart.stop.prevent
+```
+
+#### 如果要阻止默认事件,一定要写在前面,否则会影响其他事件绑定
+```
+@touchmove.stop.prevent @click.stop="show=false"
+```
+
+#### 尽量少用,用多了,感觉渲染的会慢很多。
+```
+
+ bla bla bla...
+
+```
+
+
+#### 压缩,发布生产的时候,设置 Vue.config.debug = false; 去除注释,因为某些安卓机型里面,可能会出现莫名奇妙的问题。
+