09 2022 档案
摘要:- 在未接触redux之前,兄弟组件之间共享状态,需要把状态提升到公共的父组件,然后父组件用props传给子组件,实现兄弟组件状态共享。 还有一种方法可实现兄弟组件的通信,pubsub-js npm地址:https://www.npmjs.com/package/pubsub-js pubsub-j
阅读全文
摘要:- 如果项目中就请求一个地址可以直接在package.json中配置 有点:配置简单,不用加前缀 缺点:不能配置多个代理 "proxy": "http://localhost:5000" 如果项目中需要配置多个代理 优点:可以配置多个代理 react17版本的代理配置需要在src/setupProx
阅读全文
摘要:- 假如有一个hello组件 hello组件: import { Component } from 'react' import hello from './index.module.css' // 模块化import './index.css' // 非模块化 后引入的组件,假如和前面的的组件内的
阅读全文
摘要:- react脚手架使用webpack搭建的 webpack有各种loader、plugins为我们完成很多功能;比如语法检查、代码压缩、兼容性处理、图片压缩 facebook已经为搭建好了react脚手架: create-react-app 全局安装react脚手架 npm install cre
阅读全文
摘要:- <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="
阅读全文
摘要:- 生命周期回调函数 生命周期钩子函数 生命周期函数 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta
阅读全文