react
文章平均质量分 94
小白Hard
这个作者很懒,什么都没留下…
展开
-
reactHook_useState、useCallback
import React,{useCallback, useState} from 'react'; import ReactDOM from 'react-dom'; class Counter extends React.Component{ state={ count:10 } add=()=>{ this.setState({ count:this.state.count+1 }) }...原创 2020-11-02 20:10:39 · 630 阅读 · 0 评论 -
react中的事件(this指向)
vue中的事件是@click,React中是onClick. import React from 'react'; class Counter extends React.Component{ state={ count:10 } // 需要传参数时写如下: fn(e,n){ // 是一个公有的属性 console.log(this,e,n); } // 不需要传参数时,写如下的箭头函数 fn2=(.原创 2020-11-02 10:02:13 · 202 阅读 · 0 评论 -
react中jsx语法
搭建react: (1)全局安装npm i create-react-app -g 创建项目:create-react-app 项目名 (2)直接npx create-react-app 项目名 安装时如果出现错误:Unexpected end of JSON input while parsing near ‘…t-app-2.1.8.tgz","fil’ 使用命令:npm cache clean --force react中src下的index.js相当于vue项目中main.js 想在项目中使用sc.原创 2020-11-01 16:41:01 · 114 阅读 · 0 评论