zoukankan      html  css  js  c++  java
  • 报错/Warning: You should not use <Route component> and <Route children> in the same route; <Route component> will be ignored

    这个报错在以下情形会出现

    第一种

    <Switch>
           <Route exact path="/home/index" component={HomeIndex} />
           <Route path="/home/order" component={HomeOrder}>
              <Route path="/home/order2" component={HomeOrder2}></Route>
           </Route>
           <Route path="/home/assets" component={Assets} />
        </Switch>    
    

    Route组件下面不能嵌套Route组件,react-router4版本以上就不让这么写了

    第二种(超级坑!!!)

    <Switch>
           <Route exact path="/home/index" component={HomeIndex} />
           <Route path="/home/order" component={HomeOrder}>
           </Route>
           <Route path="/home/assets" component={Assets} />
        </Switch> 
    

    Route组件之间不能有空格换行!所以,要么<Route></Route>这种样子或者写成一个自闭和标签<Route />!!!

  • 相关阅读:
    20151019
    20151013
    20150810
    20150626
    20150625
    20150530
    HTML特殊字符大全
    label标签跳出循环
    IIS 负载均衡
    .NET代码执行效率优化
  • 原文地址:https://www.cnblogs.com/liang-meng/p/11899815.html
Copyright © 2011-2022 走看看