![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
react
czx_2019
这个作者很懒,什么都没留下…
展开
-
react路由react-router-dom
使用react-router-dom 第一步npm install react-router-dom 第二步src下建立App.jsx文件,导入 路由模块 import { HashRouter, Route, Link } from 'react-router-dom' // HashRouter 表示一个路由的跟容器,将来, //所有的路由相关的东西,都要包裹在 HashRouter 里面, //而且,一个网站中,只需要使用一次 HashRouter 就好了; // Route 表示一个路由规则,原创 2020-08-17 22:19:13 · 183 阅读 · 0 评论 -
react中context实现父组件,子组件,孙子组件属性传递
这样可以实现父组件直接传递属性给孙子组件原创 2020-08-17 15:56:56 · 462 阅读 · 0 评论 -
react可以传递父组件的方法给子组件,让子组件去执行, react小demo
父组件传了一个initList的方法给子组件<ComBox>,然后子组件可以执行父组件的方法, 从而达到刷新的效果 render() { return <div style={{width: "100%", padding: "20px", border: "1px solid #ccc", boxSizing: "border-box"}}> <h1>评论列表</h1> <ComBox reload={this.i原创 2020-08-17 15:28:09 · 612 阅读 · 0 评论 -
react的input双向数据绑定
import React from 'react' export default class BindThis extends React.Component { constructor(props) { super(props) this.state = { msg: 'hello' } } render() { return <div> <h1>原创 2020-08-17 11:26:28 · 628 阅读 · 0 评论 -
react绑定this并传参的形式
方式一事件处理函数中直接绑定this并传参 export default class BindThis extends React.Component { constructor(props) { super(props) this.state = { msg: 'hello' } } render() { return <div> <h1>reac原创 2020-08-17 11:10:20 · 106 阅读 · 0 评论 -
Warning: componentWillMount has been renamed, and is not recommended for use
react废弃的生命周期函数才会出现这个问题,具体可以看这篇 https://blog.csdn.net/github_34708151/article/details/99670079原创 2020-08-17 10:18:15 · 1954 阅读 · 0 评论 -
react 中的shouldComponentUpdat,componentWillUpdate,componentDidUpdate, render
shouldComponentUpdate(nextProps, nextState) { // nextProps, nextState两者表示当前最新的值 // 而通过state和props获取的值是上一次的值 return nextState.count % 2 === 0 }原创 2020-08-17 09:03:29 · 1190 阅读 · 0 评论 -
react生命周期
原创 2020-08-17 03:43:10 · 65 阅读 · 0 评论 -
react中使用箭头函数报错
npm run build之后, 发现 需要配置@babel/plugin-proposal-class-properties 我们到babel官网搜索这个插件,https://babeljs.io/docs/en/babel-plugin-proposal-class-properties 然后 按官网说的安装 npm install --save-dev @babel/plugin-proposal-class-properties 安装好之后,webpack.config.js中按官方配置原创 2020-08-17 03:34:31 · 793 阅读 · 0 评论 -
react03组件的介绍和使用
组件生命周期 创建阶段: 只执行一次 运行阶段: 根据组件的state和props的改变执行0次或者多次 销毁阶段: 只执行 一次 不推荐使用原生的事件原创 2020-08-17 03:25:36 · 70 阅读 · 0 评论 -
使用react渲染简单评论列表demo
components/Comments.jsx文件: import React from 'react' import List from './CommentsItem.jsx' class Comments extends React.Component { constructor(props) { super(props) this.state = { commentsList: [ {name: '原创 2020-08-16 18:48:47 · 303 阅读 · 0 评论 -
react基础
混合开发两种,一种是内嵌的h5,一种是react-native构建出来的原始开发 每一个 React 元素事实上都是一个 JavaScript 对象,你可以在你的程序中把它当保存在变量中或者作为参数传递。 react没有像vue一样把一个组件拆分为三部分(结构,样式,业务逻辑),而是全部用js来实现一个组件 react几个核心概念 1虚拟dom 2diff算法 3JSX语法 DOM的本质:用js表示的ui元素 DOM和虚拟DOM的区别: DOM由浏览器中的js提供,只能人为的使用浏览器提供的固定的api操.原创 2020-08-14 23:30:15 · 118 阅读 · 0 评论