
react
Wg1xg
永远自由 清澈明朗
展开
-
‘index.js‘ does not match the corresponding name on disk: ‘.\node_modules\把react写成了React;
‘index.js’ does not match the corresponding name on disk: '.\node_modules\是import引入语句写的有问题,把react写成了React;应该是 import {React} from ‘react’;原创 2021-06-01 22:55:52 · 4245 阅读 · 1 评论 -
react form表单日期数据回显到DatePicker组件中
报错问题:Uncaught TypeError: date.clone is not a function报错原因:initialValues={this.state.formdata}初始化表单信息的时候时间回显报错:Uncaught TypeError: date.clone is not a function,原因是数据类型不匹配解决办法import moment from 'moment'; //引入momentvar valueTime = moment(value.memberent原创 2021-05-29 22:07:09 · 1908 阅读 · 0 评论 -
antd Modal中添加Form表单用ref获取数据,第一次打开取到的是null
Modal的 API中有一个强制渲染的属性给Modal加上此属性即可。forceRender={true}第一次取就可以取到了,只是会把渲染的先隐藏起来,可能会浪费些渲染性能。原创 2021-05-29 20:01:51 · 2863 阅读 · 0 评论 -
Cannot find file: ‘index.js‘ does not match the corresponding name on disk: ‘.\node_modules\React\re
Cannot find file: ‘index.js’ does not match the corresponding name on disk: ‘.\node_modules\React\react’.因为在webpack.config.js配置了自动引入React和Component解决方法把 : “React"改为"react”, new webpack.ProvidePlugin({ React: "react", //注意此处的react不要大写原创 2021-05-24 11:52:34 · 1808 阅读 · 0 评论 -
ENOENT: no such file or directory, scandir ‘E:\Demo\threeStage\react-app\node_modules\node-sass\vend
在使用npm安装node-sass的时候,可能会出现如下的报错解决方案是执行以下方法:npm rebuild node-sass原创 2021-05-23 10:56:40 · 225 阅读 · 0 评论 -
react 路由跳转报错TypeError: Cannot read property ‘props‘ of undefined
react 路由跳转报错TypeError: Cannot read property ‘props’ of undefined handleGoReg() { console.log(this.props); this.props.history.push("./register") }原因是没有给函数绑定this,函数内部引用this的时候无法解析出this,也就得不到this的属性props了。解决方法1:在组件的构造函数constructor中添原创 2021-05-22 23:35:54 · 1349 阅读 · 0 评论 -
react路由懒加载
方法一:React.lazy 接受一个函数,这个函数需要动态调用 import()。它必须返回一个 Promise,该 Promise 需要 resolve 一个 default export 的 React 组件然后应在 Suspense 组件中渲染 lazy 组件,如此使得我们可以使用在等待加载 lazy 组件时做优雅降级(如 loading 指示器等)fallback 属性接受任何在组件加载过程中你想展示的 React 元素。你可以将 Suspense 组件置于懒加载组件之上的任何位置。你甚至原创 2021-05-20 21:17:26 · 230 阅读 · 0 评论 -
react取消eslint
在package.json 中修改代码"eslintConfig": { "extends": "react-app", "rules": { "no-undef": "off", "no-restricted-globals": "off", "no-unused-vars": "off" }}原创 2021-05-19 17:48:42 · 1409 阅读 · 0 评论 -
React中的context
React中的context当我们写React时,我们总是通过改变State和传递Prop对view进行控制,有时时,也会遇到一点小麻烦。但是随着我们的应用变的越来越复杂,组件嵌套也变的越来越深,有时甚至要从最外层将一个数据一直传递到最里层(比如当前user的信息)。理论上,通过prop一层层传递下去当然是没问题的。不过这也太麻烦啦,要是能在最外层和最里层之间开一个穿越空间的虫洞就好了。幸运的是,React的开发者也意识到这个问题,为我们开发出了这个空间穿越通道 —— Context。假设我们有一转载 2021-05-18 10:46:19 · 179 阅读 · 0 评论