随笔分类 - react基础语法
摘要:react的生命周期,分为3三个阶段, 挂载阶段 constructor(){} UNSAFE_componentWillMount(){} == componentWillMount(在17版本中将废除){} componentDidMount(){ 发送异步请求的} render(){} 跟新:
阅读全文
摘要:子组件 import React, { Component } from 'react'; class Web1 extends Component { constructor(props) { super(props); this.state = { num:100, } } son(){ thi
阅读全文
摘要:爷爷组件 import React, { Component } from "react"; import "./App.css"; import TestHanderClick from "./components/TestHanderClick"; import proptypeskey fro
阅读全文
摘要:首先你需要下载 cnpm i prop-types 安装验证数据类型的插件; 子组件 import React, { Component } from "react"; import "./base.css"; // 引入验证格式类型的插件 import proptypeskey from "pro
阅读全文
摘要:父组件 <TestHanderClick bg="blue"> <p> 如果我要显示的话,父组件是双标签,子组件中有this.props.children</p> <div>类似于匿名插槽</div> </TestHanderClick> 子组件 import React, { Component
阅读全文
摘要:子组件 import React, { Component } from "react"; import "./base.css" // 父组件 export class TestHanderClick extends Component { // static defaultProps是默认的写法
阅读全文
摘要:给当前元素添加一个类是通过className来处理的; 引入css;直接from XXXX import React, { Component } from "react"; // 以内css,直接form import "./base.css" export class TestHanderCli
阅读全文
摘要:import React, { Component } from "react"; export class TestHanderClick extends Component { constructor(props) { super(props); this.state = { cont: "内容
阅读全文
摘要:执行如下: npm install -g react npm install react --save 类似这种依赖项(react,react-dom 等)报错,哪个报错执行哪个即可 执行上述两句就 ok 啦
阅读全文
摘要:我发现 state 有两种不同的写法 在构造器 constructor 中是这样的 有 this. constructor(props){//参数必须要有 super(props); this.state={ num:10 } } } 没有 constructor state={ num:10 }
阅读全文
摘要:现在安装 react 脚手架的有三种, react-boilerplate react-redux-starter-kit create-react-app(国内主要运用这一种) 1==>npm install -g create-react-app 全局安装脚手架命令(第一次安装后就不需要在重新安
阅读全文
摘要:import React, { Component } from "react"; export class TestHanderClick extends Component { //有构造器state写在里面, 构造器中必须要有super并且传递参数 constructor(props) { s
阅读全文