Akaziki

Please use higher order functions


  • 首页

  • 标签

  • 归档

  • 关于

Vue学习笔记-三

发表于 2017-11-08

部分最基本的功能

点餐菜单部分最基本的功能

组件化

项目是由vue-cli生成的vue+webpack模板基础上构建的:

1
vue init webpack OrderMenu

目前整个页面分成了8个组件: img

八个组件是分层次的:组件分层嵌套。层次的确定有的是根据功能区分,有的是根据渲染的位置和层次。根组件下只包含四个子组件:

  • menu-header:头部结构,包含店铺信息,搜索模块等;
  • menu-item:v-for渲染的list,用于显示菜品;
  • menu-cart:用于显示当前点菜的数量和价格;
  • pic-card:卡片式大图查看组件,在点击菜品缩略图时弹出;

这里组件的划分也不是最合理的,我感觉在功能划分上做的还不够好。

数据设计

既然是一个点菜的页面,那么菜品信息必然是主要的部分:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var dishs = [{
catalog: "招牌鲜鱼",
catalogID: 1100,
dishs: [{
dishID: 100,
dishName: "花鲢",
dishDesc: "约350g,原产地当日直供。本店所有鱼均由省重点养殖企业 龙华渔场 提供。",
dishPrice: 25,
likeNum: 488,
imgSrc: require('../img/hualian1.jpg'),
isCombo: false,
isPromotion: true,
searchKey: ["招牌推荐", "鱼类", "热门"],
dishNum: 0,
imgSrcs: {
smallSrcs: [],
bigSrcs: []
}
}, {
// 次分类的下一道菜品
// ...
}]
}, {
// 下一个分类
// ...
}];

在实际中页面渲染可以在客户端或者服务端,在客户端可以通过网络请求获取JSON格式的数据,或者从本地存储(localStorage)中读取,服务端渲染则是计算出可用的HTML和相应的CSS,JS直接返回给客户端。

阅读全文 »

Vue学习笔记(二)

发表于 2017-11-04

组件(Component)是 Vue.js 最强大的功能之一。组件可以扩展 HTML 元素,封装可重用的代码。在较高层面上,组件是自定义元素,Vue.js 的编译器为它添加特殊功能。在有些情况下,组件也可以是原生 HTML 元素的形式,以 is特性扩展。

组件使用

定义

1
2
3
var MyComponent = Vue.extend({
// 选项...
});

注意:Vue构造器的多数选项也可以用在 Vue.extend() 中,不过有两个特例:data 和 el。如果只是将数据直接放入创建函数中,则所有组件实例都会共享同样的数据,有时候这并不是我们希望的(实际上Vue在注册组件时直接给data对象会抛出一个警告,最终会拒绝执行data解析工作),所以可以传入一个函数作为data选项——函数返回一个真正的数据对象。

注册

全局注册

1
2
3
4
Vue.component(tag, constructor);
//like this:
Vue.component("my-component", MyComponent);

tag 表示自定义的组件名,建议使用 小写,用短杠分隔 的规则。component 是创建的组件。注册之后就可以在其它模板中使用此组件。

局部注册

局部注册的目的在于:让组件只能用在其它组件内,而不是全局都可以使用。,在实例选项 components 中注册:

1
2
3
4
5
6
7
8
9
var Child = Vue.extend({ /* ... */ });
var Parent = Vue.extend({
template: '...',
components: {
// <my-component> 只能用在父组件模板内
'my-component': Child
}
});

注册语法糖

Vue.component() 注册函数的第二个选项可以直接传入选项对象,Vue会自动调用 Vue.extend() 函数创建组件,使用方式可简化为:

1
2
3
4
5
6
7
8
9
10
11
12
13
// 在一个步骤中扩展与注册
Vue.component('my-component', {
template: '<div>A custom component!</div>'
})
// 局部注册也可以这么做
var Parent = Vue.extend({
components: {
'my-component': {
template: '<div>A custom component!</div>'
}
}
})

阅读全文 »

Flex布局笔记

发表于 2017-11-02

Flex 布局是什么

Flex是Flexible Box的缩写,意思为“弹性布局”,用来为盒状模型提供最大的灵活性。任何一个容器都可以指定为Flex布局。

1
2
3
.box{
display: flex;
}

行内元素也可以使用Flex布局。

1
2
3
.box{
display : inline-flex;
}

Webkit内核的浏览器,必须加上-webkit前缀。

1
2
3
4
.box{
display :-webkit-flex; /*Safari*/
display : flex;
}

注意,设为Flex布局以后,子元素的float、clear、和vertical-align属性将失效。

基本概念

采用 Flex 布局的元素,称为 Flex 容器(flex container),简称”容器”。它的所有子元素自动成为容器成员,称为 Flex 项目(flex item),简称”项目”。

容器默认存在两根轴:水平的主轴(main axis)和垂直的交叉轴(cross axis)。主轴的开始位置(与边框的交叉点)叫做main start,结束位置叫做main end;交叉轴的开始位置叫做cross start,结束位置叫做cross end。项目默认沿主轴排列。单个项目占据的主轴空间叫做main size,占据的交叉轴空间叫做cross size。

阅读全文 »

Vue学习笔记(一)

发表于 2017-10-30

VueJs:

数据驱动的组件,为现代化的 Web 界面而生

Vue的核心包括两部分:

  1. 响应的数据绑定:数据驱动视图,操作数据而非DOM,通过指令实现功能扩展;
  2. 组件系统:vue应用可以看成是一棵组件树,vue提供组件间的数据流,自定义事件系统,带特效的组件替换效果等;

Vue官网中专门有一篇文章讲Vue和其它框架的对比,个人觉得有点参考价值,从中可以窥见很多Vue重要的特性:

  1. 对比 angular
  • Vue专注视图层,更轻,性能占优;
  • Vue只允许父组件单向地传递数据给子组件;
  • Vue不执行脏检查,使用基于依赖追踪的观察系统,且使用异步队列更新;
  1. 对比 react
  • Vue建立在真实DOM结构上;
  • 轻量级的 DSL (指令系统),直观简洁的模板;
  • Vue也有自己的状态管理方案:Vuex;
  1. 其它特点
  • 与webpack无缝整合;
  • 支持ES6和CSS预处理器;
  • 另外在组件封装方面,下面一张图就可以很好地展现Vue的特性

vue-component

阅读全文 »

CSS样式大全

发表于 2017-10-30

本文可以作为一个平时使用的css参考手册,文章来源于网上,具体见文章末尾。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
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
279
280
281
282
283
284
字体属性:(font)
大小 {font-size: x-large;}
(特大) xx-small;(极小) 一般中文用不到,只要用数值就可以,单位:PX、PD
样式 {font-style: oblique;}
(偏斜体) italic;(斜体) normal;(正常)
行高 {line-height: normal;}
(正常) 单位:PX、PD、EM
粗细 {font-weight: bold;}
(粗体) lighter;(细体) normal;(正常)
变体 {font-variant: small-caps;}
(小型大写字母) normal;(正常)
大小写 {text-transform: capitalize;}
(首字母大写) uppercase;(大写) lowercase;(小写) none;(无)
修饰 {text-decoration: underline;}
(下划线) overline;(上划线) line-through;(删除线) blink;(闪烁)
常用字体: (font-family)
"Courier New", Courier, monospace, "Times New Roman",
Times, serif, Arial, Helvetica, sans-serif, Verdana
背景属性: (background)
色彩 {background-color: #FFFFFF;}
图片 {background-image: url();}
重复 {background-repeat: no-repeat;}
滚动 {background-attachment: fixed;}(固定) scroll;(滚动)
位置 {background-position: left;}(水平) top(垂直);
简写方法 {background:#000 url(..) repeat fixed left top;}
/*简写·这个在阅读代码中经常出现,要认真的研究*/
区块属性: (Block) /*这个属性第一次认识,要多多研究*/
字间距 {letter-spacing: normal;} 数值 /*这个属性似乎有用,多实践下*/
对齐 {text-align: justify;}
(两端对齐) left;(左对齐) rightright;(右对齐) center;(居中)
缩进 {text-indent: 数值px;}
垂直对齐 {vertical-align: baselinebaseline;}
(基线) sub;(下标) super;(下标) top; text-top; middle; bottombottom; text-bottom;
词间距word-spacing: normal; 数值
空格whitewhite-space: pre;(保留) nowrap;(不换行)
显示 {display:block;}
(块) inline;(内嵌) list-item;(列表项) run-in;(追加部分) compact;(紧凑)
marker;(标记)table; inline-table; table-raw-group; table-header-group;
table-footer-group;table-raw; table-column-group; table-column;
table-cell; table-caption;(表格标题) /*display 属性的了解很模糊*/
方框属性: (Box)
width:; height:; float:; clear:both; margin:; padding:; 顺序:上右下左
边框属性: (Border)
border-style: dotted;(点线) dashed;(虚线) solid; double;(双线)
groove;(槽线) ridge;(脊状) inset;(凹陷) outset;
border-width:; 边框宽度
border-color:#;
简写方法border:width style color; /*简写*/
列表属性: (List-style)
类型list-style-type: disc;(圆点) circle;(圆圈) square;(方块) decimal;(数字)
lower-roman;(小罗码数字) upper-roman; lower-alpha; upper-alpha;
位置list-style-position: outside;(外) inside;
图像list-style-image: url(..);
定位属性: (Position)
Position: absolute; relative; static;
visibility: inherit; visible; hidden;
overflow: visible; hidden; scroll; auto;
clip: rect(12px,auto,12px,auto) (裁切)
css属性代码大全
一 CSS文字属性:
color : #999999; /*文字颜色*/
font-family : 宋体,sans-serif; /*文字字体*/
font-size : 9pt; /*文字大小*/
font-style:itelic; /*文字斜体*/
font-variant:small-caps; /*小字体*/
letter-spacing : 1pt; /*字间距离*/
line-height : 200%; /*设置行高*/
font-weight:bold; /*文字粗体*/
vertical-align:sub; /*下标字*/
vertical-align:super; /*上标字*/
text-decoration:line-through; /*加删除线*/
text-decoration: overline; /*加顶线*/
text-decoration:underline; /*加下划线*/
text-decoration:none; /*删除链接下划线*/
text-transform : capitalize; /*首字大写*/
text-transform : uppercase; /*英文大写*/
text-transform : lowercase; /*英文小写*/
text-align:rightright; /*文字右对齐*/
text-align:left; /*文字左对齐*/
text-align:center; /*文字居中对齐*/
text-align:justify; /*文字分散对齐*/
vertical-align属性
vertical-align:top; /*垂直向上对齐*/
vertical-align:bottombottom; /*垂直向下对齐*/
vertical-align:middle; /*垂直居中对齐*/
vertical-align:text-top; /*文字垂直向上对齐*/
vertical-align:text-bottom; /*文字垂直向下对齐*/
二、CSS边框空白
padding-top:10px; /*上边框留空白*/
padding-right:10px; /*右边框留空白*/
padding-bottom:10px; /*下边框留空白*/
padding-left:10px; /*左边框留空白
三、CSS符号属性:
list-style-type:none; /*不编号*/
list-style-type:decimal; /*阿拉伯数字*/
list-style-type:lower-roman; /*小写罗马数字*/
list-style-type:upper-roman; /*大写罗马数字*/
list-style-type:lower-alpha; /*小写英文字母*/
list-style-type:upper-alpha; /*大写英文字母*/
list-style-type:disc; /*实心圆形符号*/
list-style-type:circle; /*空心圆形符号*/
list-style-type:square; /*实心方形符号*/
list-style-image:url(/dot.gif); /*图片式符号*/
list-style-position: outside; /*凸排*/
list-style-position:inside; /*缩进*/
四、CSS背景样式:
background-color:#F5E2EC; /*背景颜色*/
background:transparent; /*透视背景*/
background-image : url(/image/bg.gif); /*背景图片*/
background-attachment : fixed; /*浮水印固定背景*/
background-repeat : repeat; /*重复排列-网页默认*/
background-repeat : no-repeat; /*不重复排列*/
background-repeat : repeat-x; /*在x轴重复排列*/
background-repeat : repeat-y; /*在y轴重复排列*/
指定背景位置
background-position : 90% 90%; /*背景图片x与y轴的位置*/
background-position : top; /*向上对齐*/
background-position : buttom; /*向下对齐*/
background-position : left; /*向左对齐*/
background-position : rightright; /*向右对齐*/
background-position : center; /*居中对齐*/
五、CSS连接属性:
a /*所有超链接*/
a:link /*超链接文字格式*/
a:visited /*浏览过的链接文字格式*/
a:active /*按下链接的格式*/
a:hover /*鼠标转到链接*/
鼠标光标样式:
链接手指 CURSOR: hand
十字体 cursor:crosshair
箭头朝下 cursor:s-resize
十字箭头 cursor:move
箭头朝右 cursor:move
加一问号 cursor:help
箭头朝左 cursor:w-resize
箭头朝上 cursor:n-resize
箭头朝右上 cursor:ne-resize
箭头朝左上 cursor:nw-resize
文字I型 cursor:text
箭头斜右下 cursor:se-resize
箭头斜左下 cursor:sw-resize
漏斗 cursor:wait
光标图案(IE6) p {cursor:url("光标文件名.cur"),text;}
六、CSS框线一览表:
border-top : 1px solid #6699cc; /*上框线*/
border-bottom : 1px solid #6699cc; /*下框线*/
border-left : 1px solid #6699cc; /*左框线*/
border-right : 1px solid #6699cc; /*右框线*/
以上是建议书写方式,但也可以使用常规的方式 如下:
border-top-color : #369 /*设置上框线top颜色*/
border-top-width :1px /*设置上框线top宽度*/
border-top-style : solid/*设置上框线top样式*/
其他框线样式
solid /*实线框*/
dotted /*虚线框*/
double /*双线框*/
groove /*立体内凸框*/
ridge /*立体浮雕框*/
inset /*凹框*/
outset /*凸框*/
七、CSS表单运用:
文字方块
按钮
复选框
选择钮
多行文字方块
下拉式菜单 选项1选项2
八、CSS边界样式:
margin-top:10px; /*上边界*/
margin-right:10px; /*右边界值*/
margin-bottom:10px; /*下边界值*/
margin-left:10px; /*左边界值*/
CSS 属性: 字体样式(Font Style)
序号 中文说明 标记语法
1 字体样式 {font:font-style font-variant font-weight font-size font-family}
2 字体类型 {font-family:"字体1","字体2","字体3",...}
3 字体大小 {font-size:数值|inherit| medium| large|
larger| x-large| xx-large| small| smaller| x-small| xx-small}
4 字体风格 {font-style:inherit|italic|normal|oblique}
5 字体粗细 {font-weight:100-900|bold|bolder|lighter|normal;}
6 字体颜色 {color:数值;}
7 阴影颜色 {text-shadow:16位色值}
8 字体行高 {line-height:数值|inherit|normal;}
9 字 间 距 {letter-spacing:数值|inherit|normal}
10 单词间距 {word-spacing:数值|inherit|normal}
11 字体变形 {font-variant:inherit|normal|small-cps }
12 英文转换 {text-transform:inherit|none|capitalize|uppercase|lowercase}
13 字体变形 {font-size-adjust:inherit|none}
14 字体 {font-stretch:condensed|expanded|extra-condensed|
extra-expanded|inherit|narrower|normal| semi-condensed|
semi-expanded|ultra-condensed|ultra-expanded|wider}
文本样式(Text Style)
序号 中文说明 标记语法
1 行 间 距 {line-height:数值|inherit|normal;}
2 文本修饰 {text-decoration:inherit|none|underline|overline|line-through|blink}
3 段首空格 {text-indent:数值|inherit}
4 水平对齐 {text-align:left|rightright|center|justify}
5 垂直对齐 {vertical-align:inherit|top|bottombottom|text-top|
text-bottom|baselinebaseline|middle|sub|super}
6 书写方式 {writing-mode:lr-tb|tb-rl}
背景样式
序号 中文说明 标记语法
1 背景颜色 {background-color:数值}
2 背景图片 {background-image: url(URL)|none}
3 背景重复 {background-repeat:inherit|no-repeat|repeat|repeat-x|repeat-y}
4 背景固定 {background-attachment:fixed|scroll}
5 背景定位 {background-position:数值|top|bottombottom|left|rightright|center}
6 背影样式 {background:背景颜色|背景图象|背景重复|背景附件|背景位置}
框架样式(Box Style)
序号 中文说明 标记语法
1 边界留白 {margin:margin-top margin-right margin-bottom margin-left}
2 补  白 {padding:padding-top padding-right padding-bottom padding-left}
3 边框宽度 {border-width:border-top-width border-right-width
border-bottom-width border-left-width}
宽度值: thin|medium|thick|数值
4 边框颜色 {border-color:数值 数值 数值 数值}  
数值:分别代表top、rightright、bottombottom、left颜色值
5 边框风格 {border-style:none|hidden|inherit|dashed|solid
|double|inset|outset|ridge|groove}
6 边  框 {border:border-width border-style color}
上 边 框 {border-top:border-top-width border-style color}
右 边 框 {border-right:border-right-width border-style color}
下 边 框 {border-bottom:border-bottom-width border-style color}
左 边 框 {border-left:border-left-width border-style color}
7 宽  度 {width:长度|百分比| auto}
8 高  度 {height:数值|auto}
9 漂  浮 {float:left|rightright|none}
10 清  除 {clear:none|left|rightright|both}
分类列表
序号 中文说明 标记语法
1 控制显示 {display:none|block|inline|list-item}
2 控制空白 {whitewhite-space:normal|pre|nowarp}
3 符号列表 {list-style-type:disc|circle|square|decimal|lower-roman|
upper-roman|lower-alpha|upper-alpha|none}
4 图形列表 {list-style-image:URL}
5 位置列表 {list-style-position:inside|outside}
6 目录列表 {list-style:目录样式类型|目录样式位置|url}
7 鼠标形状 {cursor:hand|crosshair|text|wait|move|help|e-resize|
nw-resize|w-resize|s-resize|se-resize|sw-resize}

文章来源:https://150643.com/442.html

1234

Akaziki

16 日志
13 标签
GitHub E-Mail Facebook
© 2017 — 2018 Akaziki
由 Hexo 强力驱动
|
主题 — NexT.Pisces v5.1.3