React 报错笔记

1、
错误:.ERROR in ./src/ChargeBikeAssets.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
ReferenceError: Unknown plugin “import” specified in “C:\Users\yangdezhi\Desktop\chargebike-remake\.babelrc” at 1, attempted to resolve relative to “C:\Users\yangdezhi\Desktop\chargebike-remake”
at C:\Users\yangdezhi\Desktop\chargebike-remake\node_modules\babel-core\lib\transformation\file\options\option-manager.js:180:17
at Array.map ()
at Function.normalisePlugins (C:\Users\yangdezhi\Desktop\chargebike-remake\node_modules\babel-core\lib\transformation\file\options\option-manager.js:158:20)
at OptionManager.mergeOptions (C:\Users\yangdezhi\Desktop\chargebike-remake\node_modules\babel-core\lib\transformation\file\options\option-manager.js:234:36)
at OptionManager.init (C:\Users\yangdezhi\Desktop\chargebike-remake\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
at File.initOptions (C:\Users\yangdezhi\Desktop\chargebike-remake\node_modules\babel-core\lib\transformation\file\index.js:212:65)
at new File (C:\Users\yangdezhi
原因:缺少插件 babel-plugin-import

解决方法:npm install babel-plugin-import --save-dev  或   yarn add babel-plugin-import --dev 

2 .使用webStrom的时候 整个页面都报错
在这里插入图片描述
在这里插入图片描述
(1) 原因:javaScript 版本问题 应将Es5 设置成React JSX
(2) 解决办法 :https://www.cnblogs.com/pizitai/p/6830470.html

3.react中componentWillReceiveProps()在props不改变的时候也可能被调用,导致页面重复渲染 修改的值赋不上

解决办法:componentWillReceiveProps 里面判断依稀 this.props和nextProps 是否相等 如果相等说明 props值没有改变,就不要setState .

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值