React-router引入IndexRoute报错

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 routes

Warning: [react-router] An <IndexRoute> does not make sense at the root of your route config

IndexRoute组件里的Home组件是正常的,单独拿出来也能显示,实在不清楚报错的原因


慕标5832272
浏览 1835回答 1
1回答

陪伴而非守候

例子上是这个样子的,你是不是写的结构有问题?<Router>&nbsp; <Route path="/" component={App}>&nbsp; &nbsp; <IndexRoute component={Home}/>&nbsp; &nbsp; <Route path="accounts" component={Accounts}/>&nbsp; &nbsp; <Route path="statements" component={Statements}/>&nbsp; </Route></Router>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript