React
sonder 大杯

React

React 是 facebook 出的一款针对 view 视图层的 library(库)。在使用 react 做项目的时候可以结合很多第三方的插件做开发。

jsx

在 js 文件中可以直接写 html 标签

react 基础回顾

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
1. 组件定义
function
class
定义的组件有自己的局部状态和生命周期函数
state, 如果要改变state必须使用方法setState
setState是异步的
this.setState({
xx:xx
})
2. 父子组件之间传值
父传子 props属性
子传父 方法调用

3. 样式定义
className代替class
style指定样式的时候需要使用一个对象作为参数,样式名字需要使用驼峰的命名方式

4. jsx语法
在js代码中插入html标签
{} 数据绑定展示
map
if 判断
三元表达式
https://www.runoob.com/react/react-jsx.html

5. ajax请求

6. 事件绑定


  • 本文标题:React
  • 本文作者:sonder
  • 创建时间:2019-07-29 20:48:32
  • 本文链接:https://sonderss.github.io/2019/07/29/React/
 评论