屬性「位置」這是我第一次使用React JS
,我堅持了這個錯誤,陣營JS無法讀取的不確定
我試圖汲取這次video 反應路由器也看了多次,但我仍然無法找到並解決問題:
的package.json
{
"name": "cobareact",
"version": "1.0.0",
"description": "app pertama react",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --hot"
},
"author": "",
"license": "ISC",
"dependencies": {
"babel-core": "^6.24.1",
"babel-loader": "^7.0.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"history": "^1.17.0",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"react-router": "^4.1.1",
"react-router-dom": "^4.1.1",
"webpack": "^2.5.1",
"webpack-dev-server": "^2.4.5"
},
"devDependencies": {
"webpack": "^2.5.1"
}
}
main.js
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, IndexRoute, hashHistory } from 'react-router';
import App from './App.jsx';
import About from './About.js';
import Add from './Add.js';
ReactDOM.render(
<Router history={hashHistory}>
<Route path='' component={App}>
<IndexRoute component={About}></IndexRoute>
<Route path='about' component={About}></Route>
<Route path='add' component={Add}></Route>
</Route>
</Router>,
document.getElementById('app')
);
App.jsx
import React from 'react';
import ButtonAdd from './ButtonAdd';
import ButtonAbout from './ButtonAbout';
import Contacts from './Contacts';
import { Link } from 'react-router';
class App extends React.Component{
render() {
return (
<div>
<div>
{this.props.children}
<div><Link to="add"><ButtonAdd /></Link><Link to="about"><ButtonAbout /></Link></div>
<h1>Contact Book</h1>
</div>
<div>
<Contacts lists={CONTACTS} />
</div>
</div>
);
}
}
export default App;
錯誤
Uncaught TypeError: Cannot read property 'location' of undefined`enter code here`
警告
警告:無法道具鍵入:道具history
標記爲Router
中的要求,但其值爲undefined
。 在路由器
感謝它的工作,當我點擊按鈕 它不顯示任何東西, 我使用{this.props.children}相同的視頻,但 當我console.log(this.props)我找不到兒童對象 對不起,這是我第一次 –