在Vue 中有三种方式能够实现组件通讯:javascript
在 React 中,也有对应的三种方式:html
父组件经过 props 能够向子组件传递数据或者回调前端
能够经过 context 进行跨层级的通讯,这其实和provide/inject 起到的做用差很少。 能够看到,React自己并不支持自定义事件,Vue中子组件向父组件传递消息有两种方式:事件和回调函数,并且Vue更倾向于使用事件。可是在 React 中咱们都是使用回调函数的,这多是他们两者最大的区别。vue
4)模板渲染方式的不一样:java
Axios的特色node
基本用法react
//执行get请求
axios.get('/user?ID=12345')
.then(function (response) {
console.log(response);
}).catch(function (error) {
console.log(error);
});
axios.get('/user', {
params: {
ID: 12345
}
}).then(function (response) {
console.log(response);
}).catch(function (error) {
console.log(error);
});
复制代码
没有ios
rem是根元素字体的单位,好比 html{font-size:16px;} ,1rem至关于16px面试
经过修改根节点的font-size大小,实现等比例缩放vuex
一、给根元素设置字体大小,并在body元素校订 - html{font-size:100px;} - body{font-size:14px;}
.menu li{
display: table-cell;
padding: .1rem .3rem;/*至关于10px 30px*/
}
复制代码
二、绑定监听事件,dom加载后和尺寸变化时改变font-size
详细解析: juejin.im/post/5caaa2…
<style>
*{
margin: 0;
}
.one{
position: relative;
width: 100%;
height: 500px;
background: #c5c5c5;
}
.two{
position: absolute;
left: 50%;
top:50%;
margin-left: -100px;
margin-top: -100px;
background-color: #a00;
width: 200px;
height: 200px;
}
</style>
<div class="one">
<div class="two"></div>
</div>
复制代码
<style>
*{
margin: 0;
}
.one{
position: relative;
width: 100%;
height: 500px;
background: #c5c5c5;
}
.two{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
background-color: #a00;
width: 200px;
height: 200px;
}
</style>
<div class="one">
<div class="two"></div>
</div>
复制代码
<style>
*{
margin: 0;
}
.one{
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 500px;
background: #c5c5c5;
}
.two{
background-color: #a00;
width: 200px;
height: 200px;
}
</style>
<div class="one">
<div class="two"></div>
</div>
复制代码
由上面的三个值所产生一个原理公式:
scrollTop + clientHeight >= scrollHeight
let clientHeight = document.documentElement.clientHeight; //浏览器高度
let scrollHeight = document.body.scrollHeight;
let scrollTop = document.documentElement.scrollTop;
let distance = 50; //距离视窗还用50的时候,开始触发;
if ((scrollTop + clientHeight) >= (scrollHeight - distance)) {
console.log("到底了,开始加载数据");
}
复制代码