我在main.jsx(入口点)中有以下路由,
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route,IndexRoute, browserHistory } from 'react-router';
function render(){
ReactDOM.render((
<Router history={browserHistory}>
<Route path="/" component={Home} />
<Route path="/viewq/:id" component={v}/>
<Route path="/postq/:id" component={p}/>
</Router>
), document.getElementById("app"));
}
render();
当我访问以下网址时,例如host / viewq / id = 14,组件未被渲染。
拥有以下server.js文件,以返回带有捆绑文件(main.js)的index.html,
app.get('*', function (request, response){
response.sendFile(path.resolve(__dirname, 'dist', 'index.html'))
})
如何使这项工作?