我實現了一個反應JS測試應用程序與ES6反應的路由器,但它似乎並沒有工作。下面的代碼片段:陣營路由器導航不起作用
app.js
-------
import React from 'react';
import ReactDOM from 'react-dom';
import Routes from './routes';
ReactDOM.render(Routes, document.getElementById('react-container'));
routes.js
---------
import React from 'react';
import { DefaultRoute, Link, Route, RouteHandler,Router } from 'react-router';
import Page1 from './page1';
import Home from './home';
import { IndexRoute } from 'react-router';
let routes =
<Router>
<Route path="/" component={Home}>
<Route path="page1" component={ Page1 }/>
</Route>
</Router>
export default routes
home.js
-------
import React, { Component } from 'react';
import Header from './components/header';
export default class Home extends Component {
constructor() {
super();
}
render() {
return (
<div>
<Header />
{this.props.children}
</div>
);
}
}
page1.js
--------
import React, { Component } from 'react';
export default class Page1 extends Component {
constructor() {
super();
}
render() {
return (
<div>
<h1> Page 1 </h1>
</div>
);
}
}
導航到「/」和「/ page1」似乎落在僅指示標題部分的頁面中。任何幫助讚賞。
你能向我們展示第1頁分量什麼辦法? –
@NaderDabit page1.js也包含在上面。 – KarthikJ