Skip to content

Commit 6e0252f

Browse files
committed
12.31
1 parent e995260 commit 6e0252f

File tree

12 files changed

+1423
-9
lines changed

12 files changed

+1423
-9
lines changed

01node.md/01whatIsNode.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
### 零时储存信息文件
2+
3+
4+
5+
npm
6+
7+
#### yarn的安装:
8+
9+
1. 下载node.js,使用npm安装
10+
`npm install -g yarn`
11+
`查看版本:yarn --version`
12+
13+
2. 安装node.js,下载yarn的安装程序:
14+
[提供一个.msi文件,在运行时将引导您在Windows上安装Yarn](https://yarnpkg.com/en/docs/install#windows-stable)
15+
16+
3. Yarn 淘宝源安装,分别复制粘贴以下代码行到黑窗口运行即可
17+
18+
```shell
19+
yarn config set registry https://registry.npm.taobao.org -g
20+
yarn config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass -g
21+
```
22+
23+
npm -g // 全局安装
24+

04vue/HYmall.md

Lines changed: 305 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,305 @@
1+
### HYmall(电商)
2+
3+
最新接口地址:baseURL = http://152.136.185.210:7878/api/m5
4+
5+
6+
7+
| | 进度 | Detial时间 |
8+
| ---- | ---- | ---------- |
9+
| | | |
10+
| | | |
11+
| | | |
12+
| | | |
13+
14+
15+
16+
### 滚动框架
17+
18+
i-scroll=> [*better-scroll*](https://github.com/ustbhuangyi/better-scroll)
19+
20+
##### Install
21+
22+
```shell
23+
npm install better-scroll -S # install 2.x,with full-featured plugin.
24+
25+
npm install @better-scroll/core # only CoreScroll
26+
import BetterScroll from 'better-scroll'
27+
28+
let bs = new BetterScroll('.wrapper', {
29+
movable: true,
30+
zoom: true
31+
})
32+
33+
import BScroll from '@better-scroll/core'
34+
35+
let bs = new BScroll('.wrapper', {})
36+
```
37+
38+
注意一定要开启点击事件
39+
40+
```js
41+
this.scroll = new BScroll(wrapper, {
42+
click: true,
43+
});
44+
```
45+
46+
47+
48+
49+
50+
### 图片懒加载
51+
52+
```js
53+
// 导包Lazyload
54+
// 懒加载注册
55+
Vue.use(Lazyload, {
56+
preLoad: 1,
57+
loading: require('@/assets/img/common/placeholder.png')
58+
});
59+
```
60+
61+
62+
63+
### 一、CSS
64+
65+
### 01 如何让很多的文字(p标签)只显示一行,且后面显示...
66+
67+
用white-space + text-overflow + overflow(让边界的文字隐藏)
68+
69+
1 **white-space**
70+
71+
规定段落中的文本不进行换行:
72+
73+
```
74+
p{
75+
white-space: nowrap
76+
}
77+
```
78+
79+
2 **css3:text-overflow**
80+
81+
css3:text-overflow 属性规定当文本溢出包含元素时发生的事情。
82+
83+
|| 描述 | 测试 |
84+
| :------- | :----------------------------------- | :----------------------------------------------------------- |
85+
| clip | 修剪文本。 | [测试](https://www.w3school.com.cn/tiy/c.asp?f=css_text-overflow) |
86+
| ellipsis | 显示省略符号来代表被修剪的文本。 | [测试](https://www.w3school.com.cn/tiy/c.asp?f=css_text-overflow&p=2) |
87+
| *string* | 使用给定的字符串来代表被修剪的文本。 | |
88+
89+
### 02 如何让很多的图片分列显示?
90+
91+
用flex布局 + flex-wrap: wrap + 图片父元素宽度设置+ 图片宽度设置
92+
93+
解释:
94+
95+
用flex布局:让内部元素呈列显示
96+
97+
flex-wrap: wrap :为了不让多余元素显示在一行,就包裹一下,显示在容器下面
98+
99+
图片父元素宽度设置:50%==2列,33.33%==3列,依次
100+
101+
图片宽度:100%为了让图片填充整个父窗口
102+
103+
### 03 如何让fixed布局的宽度占满整个屏幕的宽度?
104+
105+
```css
106+
{
107+
position: fixed;
108+
left: 0; /* 当然也可以用width: 100% */
109+
right: 0;
110+
}
111+
```
112+
113+
### 04 回忆Bscroll容器是如何在屏幕中间显示的?
114+
115+
注意自己没有用到height,这里的自己表示Bscroll
116+
117+
1. 定位:让bs的父元素设置relative,自己设置absolute,让后left:0; right:0;
118+
119+
2. 挤自己:top: 44px; bottom:49px; 把自己挤到中间去
120+
121+
3. 视口:让bs的父元素设置100个视口,height: 100vh; 如果不设置值,则盒子塌陷,如果设置px值,则无效(待确认)
122+
123+
### 05 如何画一个三角形?
124+
125+
考察border
126+
127+
transparent表示透明,三边透明一遍亮
128+
129+
```css
130+
{
131+
width: 0px; /* 宽度一定为0 */
132+
boder-width: 200px;
133+
boder-style: solid;
134+
boder-color: transparent #00F transparent transparent
135+
136+
}
137+
```
138+
139+
140+
141+
142+
143+
144+
### 二、Vue
145+
146+
### 00 HYmall开发流程是什么?
147+
148+
tabbar->
149+
150+
​ Home(navbar-> bscroll-> swiper-> recommend-> feature-> tabControl-> goods-> backUp)
151+
152+
### 00 axios如何封装?
153+
154+
```js
155+
// 导包 axios
156+
const originAxios = import('axios')
157+
158+
// 根据不同业务需求(服务器地址变更),可以配置、导出多个axios
159+
const axios = (options)=>{
160+
161+
return new Promise((resolve, reject)=>{
162+
// 创建公共部分
163+
const instance = originAxios.create({
164+
baseURL: '',
165+
timeOut: 3000,
166+
})
167+
168+
// 拦截,中间件
169+
instance.interceptors.request.use((config)=>{
170+
// 进行一些操作
171+
return config
172+
})
173+
instance.interceptors.response.use((res)=>{
174+
// 进行一些操作
175+
return res
176+
})
177+
178+
instance(options).then((res)=>{
179+
resolve(res)
180+
}).catch((err)=>{
181+
reject(err)
182+
})
183+
184+
})
185+
}
186+
const axios1 = ()=>{} // 类似于axios配置
187+
188+
export axios
189+
export axios1
190+
```
191+
192+
193+
194+
### 00 商品列表数据结构如何理解?
195+
196+
```js
197+
goods:{
198+
'pop': {page: 1, list: []},
199+
'new': {page: 1, list: []},
200+
'sell': {page: 1, list: []},
201+
}
202+
```
203+
204+
为什么不直接用一个goods变量接收,或者用多个对象pop、new、sell接收呢?
205+
206+
这样设计有三个好处:
207+
208+
1. 可以拿到page,每个good都有自己的page,方便请求下一页数据(+1即可)
209+
2. 数据统一,可以通过type来区分不同数据,例如type=='pop'及代表pop数据
210+
3. 可以用数字来对应pop、new、sell,正好切换title的时候有一个currentIndex
211+
212+
### 01 $bus是个什么?
213+
214+
事件总线
215+
216+
作用:相当于vuex,只不过她是传递事件,处理事件的。
217+
218+
用法:
219+
220+
```js
221+
(发送) this.$bus.$emit('aaa',index)
222+
(接收) this.$bus.$on('aaa', (index)=>{})
223+
(注册) Vue.prototype.$bus = new Vue()
224+
```
225+
226+
### 02 Bscroll 计算高度bug如何解决?
227+
228+
思想:由于bs里面有大量图片(且为异步数据),则会出现计算可滚动高度错误。解决方法就是给每个图片添加**load事件**,发给Home(通过$bus,也叫事件总线),让Home去调用Scroll的refresh()方法,重新计算高度。
229+
230+
这里就涉及到一个**防抖函数**
231+
232+
```js
233+
function debounce(callback, delay){
234+
let timer = null
235+
236+
return (...argv)=>{ // 必须为箭头函数,否则内部this指向错误
237+
// argv是为了给回调函数传递参数
238+
if(timer) clearTimeOut(timer)
239+
timer = setTimeOut(()=>{
240+
callback.apply(this, argv)
241+
}, delay)
242+
}
243+
}
244+
// 怎么用呢?
245+
// 1 在要防抖的外部把防抖函数拿到
246+
const refresh = debunce(callback, 300)
247+
248+
// 2 再将refresh放入抖动、反复执行的方法中
249+
// 比如监听一个刷新事件,这个事件可能会反复、频繁的调用,防抖主要靠内部的timer变量
250+
this.$bus.$on('refresh', ()=>{
251+
refresh()
252+
})
253+
```
254+
255+
### 099 注意props默认参数问题
256+
257+
如果props默认参数类型为{} or []
258+
259+
则要这样:
260+
261+
```js
262+
{
263+
type: Object,
264+
default: ()=>{return {}} // 默认值为一个函数,否则浅拷贝
265+
}
266+
```
267+
268+
### 099 Bscroll参数汇总
269+
270+
```js
271+
{
272+
cick: true, // 是否允许响应点击事件
273+
probeType: 3, // 记录滚动数字方式,3-滚动,且滚性数字
274+
pullUpLoad: true, // 允许上拉加载事件
275+
}
276+
```
277+
278+
### 三、JS
279+
280+
### 00 箭头函数this是谁?
281+
282+
箭头中this就是上下文环境的this,且无法通过bind三兄弟修改
283+
284+
普通中this就是调用者
285+
286+
### 01 bind, call, apply
287+
288+
这三个是什么 ? 我称bind三兄弟
289+
290+
她们可以改变调用函数的内部this指向
291+
292+
```js
293+
const obj=()=>{
294+
console.log(this)
295+
}
296+
const arr = new Array()
297+
arr.bind(obj) // 不能传参
298+
arr.call(obj, aaa) // 只能传一个
299+
arr.apply(obj, aaa, bbb, ccc, [...]) // 可以传无数个
300+
```
301+
302+
303+
304+
305+

0 commit comments

Comments
 (0)