├── README.md
├── compile.html
├── index.html
├── router.html
├── test.html
├── vue.js
├── vueCpu
├── echarts2.js
└── index.html
├── vuex.html
└── weather
├── EasePack.min.js
├── TweenLite.min.js
├── index.css
├── index.html
├── index.js
├── rAF.js
├── vue-resource.js
└── vue.js
/README.md:
--------------------------------------------------------------------------------
1 | # vue-demo
2 | 非单页面组件的vue+vue router+vue validator
3 | > :car:validator组件demo:(点这里)[ https://holidaying.github.io/vue-demo/index.html]
4 |
5 | > :car:vuex demo:(点这里)[ https://holidaying.github.io/vue-demo/vuex.html]
6 |
7 | > :car:vue router demo:(点这里)[ https://holidaying.github.io/vue-demo/vuex.html]
8 |
9 | > :car:vue resource demo:(点这里)[ https://holidaying.github.io/vue-demo/weather/index.html]
10 |
11 | > :car:vue CPU demo:(点这里)[ https://holidaying.github.io/vue-demo/vueCpu/index.html]
12 |
13 | 主图
14 | 
15 | ##1、首先这是单页面(cdn引入),非单独文件组件开发(npm构建的)。
16 | ```
17 |
18 |
19 | ```
20 | ##2、页面布局
21 | ```
22 |
23 |
24 |
39 |
40 |
46 |
47 |
48 |
49 |
50 |
51 | ```
52 | > 对应四个组件
53 |
54 | 
55 | ##3、启动vue
56 | ```
57 | var example1 = new Vue({
58 | el: '#app',
59 | data: {
60 | listItems: [{
61 | message: 'Foo',
62 | name:"web前端",
63 | author:"aaaa",
64 | place:"前端",
65 | url:'zhuanlan.zhihu.com',
66 | }, {
67 | message: 'Foo',
68 | name:"web前端",
69 | author:"dddd",
70 | place:"前端",
71 | url:'zhuanlan.zhihu.com',
72 | }],
73 | navBar: [
74 | ["问答", "专栏", "头条"],
75 | ["前端", "后端", "iOS", "Android", "安全", "工具", "程序员"]
76 | ],
77 | username:"",
78 | comment:"",
79 | },
80 | methods:
81 | {
82 | submit:function (argument) {
83 | if(argument.valid)
84 | {
85 | alert("用户名:"+this.username+'(评论:'+this.comment+')');
86 | }
87 | else
88 | {
89 | alert("无效");
90 | }
91 | }
92 | }
93 | ```
94 | ##4、利用vue-validator校验
95 | > 前提条件
96 | * 1.下载vue-validator文件
97 | * 2.定义validator标签,并定义name属性,以便校验时使用
98 | * 3.form中添加novalidate属性
99 | * 4. 本章校验的逻辑是当username有值时显示提交按钮,没有值时显示错误的提示信息;当评论数超过11个字符时,错误信息出现。
100 | * 5.当点击提交按钮时,如果username有值,同时评论数小于11个字符时,调用submit函数显示成功,否则失败
101 | * 6. 主要用的是v-validate:username="['required']",v-validate:comment="{maxlength: 11}" ,argument.valid等校验语法
102 | * 7.当输入框的语法不符合规范时,$validation1.username.required取他们的值就为true;当所有的语法符合规范时$validation1.valid才为true
103 |
--------------------------------------------------------------------------------
/compile.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | {{text}}
7 |
8 |
70 |
71 |