为了账号安全,请及时绑定邮箱和手机立即绑定

React-router引入IndexRoute报错

React-router引入IndexRoute报错

慕标5832272 2018-10-11 15:19:21
import React from 'react'import { Router, Route, IndexRoute, hashHistory } from 'react-router'import Frame from '../layouts/Frame'import Home from '../views/Home'import Detail from '../views/Detail'const routes = (    <Router history={hashHistory}>            <Route path="/" component={Frame} />        <IndexRoute component={Home} />        <Route path="/detail:id" component={Detail} />    </Router>)export default routesWarning: [react-router] An <IndexRoute> does not make sense at the root of your route configIndexRoute组件里的Home组件是正常的,单独拿出来也能显示,实在不清楚报错的原因
查看完整描述

1 回答

?
陪伴而非守候

TA贡献1757条经验 获得超8个赞

例子上是这个样子的,你是不是写的结构有问题?

<Router>

  <Route path="/" component={App}>

    <IndexRoute component={Home}/>

    <Route path="accounts" component={Accounts}/>

    <Route path="statements" component={Statements}/>

  </Route>

</Router>


查看完整回答
反对 回复 2018-11-16
  • 1 回答
  • 0 关注
  • 1834 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信