;}aLY5|mCAg&3n80L3UmG5T(Z-&gxfMFoBf>OlIB%IfTe%5k!e}|b{
z3j$oJ>vKM@aZs`l_Atvk4aLTfHZlkRjBl-hOX!u#mLIxBlmMlU35sduTk-ZV=EMc~
zAQ(l+O?rMdvf`;k3oJ9Qge=1|M8;8Wkg=_U$>YYMQpZ2EYd)*8-H9EiN~vTAZ6=1p%$m
zoUn==2pzP&h>p-*s?h^zGsCeaov_T9|}}M-p-4<`+3G77aM7C
zq8Y#d3;B4U67%`@ZyKzD=0+~R)LLT>e!6xlhUJ=kp4>_I)crF~s5@44itiFfhJBQ`
zN5#*Ya9E+69gh@i{QWR8ss|C#+5NpX3^H~Gz~
z{yzC#g>^QqJG&I2u7FH<7kiCL^Gg!RdF@b5>^n|*qR3#_9PyzoR`8dB-z2E~pS
z1b&Z)qe^z5Az{#sk(o~b@g2g-MYNLQj-bCm2$-;0#svUtoyBzJ2q>=?|=X%xot4y3)1zp)YtKAfrN_
zgLp%0c{Evf?gs?P3ORgqvtZ-R&hLlkejvu-9O_XD+_ngMZs~N;hRt5>80_f7H~XiG
z#OVNb!yQgj!TC|f(+mBI4?c=mHXhqy=NmJOry~*PKd@T}=W(2-KS+hqK`fuBWJ0nd
zK~4^t6-=ft!AkRgxzh*8{GV3^!QubyHsSw$ArSb$zi%M^PhhqAi_3fv?V?LpUOc=u
Q0;qtfDQPQK$Xh-7e+`t7*Z=?k
literal 0
HcmV?d00001
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; 去除注释,因为某些安卓机型里面,可能会出现莫名奇妙的问题。
+