我正在嘗試使用react-router-dom 4,但無法直接導航到路由。react-router-dom 4路由問題
這裏是我的代碼示例:
let Test = (props) => (<div>This is a test component</div>);
let About = (props) => (<div>About us</div>);
class App extends Component {
render() {
return (
<Router>
<div>
<nav>
<NavLink to="/about" activeClassName="selected">About</NavLink>
<NavLink to="/" activeClassName="selected">Test</NavLink>
</nav>
<Route exact path="/" component={Test} />
<Route exact path="/about" component={About} />
</div>
</Router>
)
}
}
當我嘗試只是去localhost:3000/about
,我得到在瀏覽器中未找到。但是當我去localhost:3000
,然後點擊關於鏈接,我重定向就好了。
在我的控制檯,我得到
Uncaught Error: uBlock Origin: aborting content scripts for http://localhost:3000/about at contentscript.js:90
你可以在[真實世界的React App這裏]看到這個工作(https://github.com/ModusCreateOrg/budgeting-sample -app-webpack2) – Grgur