react
文章平均质量分 54
react框架
Southern Wind
前端
展开
-
React——04高阶组件之Render Props
Render Props – Reactrender props 本质上是使用到了回调的方式来通信。只不过在传统的 js 回调是在构造函数中进行初始化(使用回调函数作为参数),而在 react 中,现在可以通过 props 传入该回调函数,也就是现在的 render prop。官网中给出了一种就是用鼠标移动事件做的一个封装的Render Props方便可以进行复用看这里的一个代码:(当鼠标放在浏览器可视区的时候会出现对应的鼠标坐标 )import React, { Component }原创 2021-12-26 10:56:50 · 532 阅读 · 0 评论 -
React——03children属性
Children是顶层API之一;this.props.的对象属性和组件属性是一一对应的,但是有一个例外,this.props.children是组件所有的子节点先看代码class App extends Component{ render(){ return( <div> {this.props.children} </div> ) }}co原创 2021-12-23 20:16:44 · 331 阅读 · 0 评论 -
React——02组件生命周期
目录挂载更新卸载总结如下:本章节将讨论一下React的生命周期组建的生命周期可以分为三个状态:Mounting(挂载):已经插入真实的Dom Updating(更新):正在被重新渲染的状态 Unmounting(卸载):已经移除真实的Dom看下面一张图,网址在这里挂载当组件被创建并插入在Dom中的时候,调用生命周期的顺序如下:constructor(): 在 React 组件挂载之前,会调用它的构造函数。child render():渲染过程...原创 2021-12-23 19:44:17 · 669 阅读 · 0 评论 -
React——使用生命周期写一个当前时间
import React from "react";import ReactDOM from "react-dom";import "./index.css";export default class App extends React.Component { state = { timer: new Date().toLocaleTimeString(), }; componentDidMount() { this.tick(); } componentWill.原创 2021-12-21 19:55:20 · 253 阅读 · 0 评论 -
React——01安装脚手架以及渲染标签
npx create-react-app object原创 2021-12-07 13:45:10 · 506 阅读 · 0 评论