您的位置:首页 > 其它

在Rect 中遇到的一个bug!!!

2020-05-30 21:51 82 查看

在Rect 中遇到的一个bug

index.js:1 Warning: React does not recognize the `computedMatch` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `computedmatch` instead. If you accidentally passed it from a parent component, remove it from the DOM element.

百度翻译一下 结果是这样d

索引.js:1警告:React无法识别DOM元素上的“computedMatch”属性。如果您有意希望它作为自定义属性出现在DOM中,请将其拼写为小写的“computedmatch”。如果意外地从父组件传递它,请将其从DOM元素中移除。

其实这个问题 内有那么复杂
代码如下

```javascript
import React, { Component ,Fragment} from 'react';
<Switch>

{
roleType >= 2 ?

<div>
<Route path="/user-manage" component= {Users}/>
{ roleType >= 3 ?
<div>
{/* 1用户权限-用户列表   2权限管理-权限列表,角色列表  3人员管理 */}
{/* 1用户管理-用户列表   */}
<Route path="//user-manage/users" component={Users} />
<Route path="/right-manage" component={Manage}/>
{/* 2权限管理-权限列表,角色列表  */}
<Route path="right-manage/rights"component={Rights}/>
<Route path="right-manage/roles"component={Roles}/>

{/* 3 小区 体温 人员管理   */}
<Route path="/renyuanguanli" component={Renyuan}/>
<Route path="/tiwenguanli" component={Tiwengl}/>

</div>
:
null
}
</div>

: null
}

<Route path="*" component={Error}/>

</Switch>
分析原因: 就是 Switch 包含了div 导致的
<Switch>
<div></div>

<Switch>
解决方案
<div></div>   换成   <Fragment></Fragment>  并引入标签就可以了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: