1、建立react项目css
1.安装node npm、并检验是否安装成功(node -v、npm -v)node
2.npx create-react-app small-app(建立react项目工程)react
cd small-appnpm
npm run start数组
2、render函数bash
每一个组件必须返回一个render函数,这个 render 方法必需要返回一个 JSX 元素。 必需要用一个外层的 JSX 元素把全部内容包裹起来,返回并列多个 JSX 元素是不合法的.app
3、事件方法函数
handClickAction(参数){具体实现过程}
复制代码
4、map遍历数组ui
要实现以下图功能: spa
const list = []
list.map((item,index)=>{
return(<Li key={index}>{item}</Li>)
})
复制代码
5、css样式写法
1.本文件中
<input style={inputStyle}></input>
const inputStyle =
{
marginLeft:'15px',
marginTop:'10px',
width:'200px',
height:'30px',
}
2.css文件中
.MyStyle{
text-align: left;
font-size: 18px;
color: red;
background-color: lightgoldenrodyellow;
}
采用<input className='Mystyle'></input>
复制代码