照着文档来的,代码如下:
import React from 'react'
import ReactDOM from 'react-dom'
import { Router, Route, Link ,browserHistory} from 'react-router'
import { IndexRoute } from 'react-router'
const Dashboard = React.createClass({
render() {
return (Welcome to the app!
)
}
})
const App = React.createClass({
render() {
return (
App
- About
- Inbox
{this.props.children}
)
}
})
const About = React.createClass({
render() {
return (About
);
}
})
const Inbox = React.createClass({
render() {
return (
Inbox
{this.props.children || "Welcome to your Inbox"}
)
}
})
const Message = React.createClass({
render() {
return (Message {this.props.params.id}
)
}
})
ReactDOM.render((
), document.getElementById('root'))
但是会报错:
点进去后是这样的:
!history.getCurrentLocation ? process.env.NODE_ENV !== 'production' ? (0, _invariant2.default)(false, 'You have provided a history object created with history v2.x or ' + 'earlier. This version of React Router is only compatible with v3 ' + 'history objects. Please upgrade to history v3.x.') : (0, _invariant2.default)(false) : void 0;
到底是什么原因啊
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
我也遇到这个问题,我是着么解决的。
在后面的
ReactDOM.render换乘render类似这样