随笔分类 - React
从零开始的学习React
摘要:安装 npm i react-router-dom 在app.js或者index.js中使用 class App extends Component { render() { return ( <BrowserRouter> <Switch>{/*只访问一个*/} <Route exact path
阅读全文
摘要:前提是安装了npm和node npm或cnpm命令创建项目: cnpm install -g create-react-app >>( npm install -g create-react-app ) create-react-app my-app (my-app是你自己的项目名称 自定义) 创建
阅读全文
摘要:渲染多个组件 function NumberList(props) { const numbers = props.numbers; const listItems = numbers.map((number) => //不写key会看到警告 a key should be provided for
阅读全文
摘要:逻辑与运算符 && true && expression : 返回expression false && expression :忽略并跳过 三元运算 condition ? true : false 阻止组件渲染 : 给props传入一个bool值 如果为假render方法返回null 而不进行任
阅读全文
摘要:传统HTML: <button onclick = "f1()"> Activate Lasers </button> React: <button onclick = {f1()}> Activate Lasers </button> 绑定this:==> onClick = {this.hand
阅读全文
摘要:生命周期: mount(挂载) uunmount(卸载) componentDidMount() 组件渲染到DOM后运行 未完待续...
阅读全文
摘要:定义javascript函数组件: function zjName (props) { return <h1>Hello, {props.name}</h1>; } 使用ES6的class定义组件: class zjName extends React.Component { render() {
阅读全文

浙公网安备 33010602011771号