加入代码中有这样一个路由需要渲染;
render( <Router history = {browserHistory} > <route path ="/" component={App} > <IndexRoute component={Home} /> <route path ="/jianjie" component={jianjie} /> <route path ="/yewu" component={yewu} /> <route path ="/lianxi" component={lianxi} /> <route path ="/about" component={About} /> <route path ="/test" component={test} /> </route></Router>, ele)
但是App组件是这样的;
import React ,{ Component }from 'react';import Nav from './nav';import Foot from './foot';class App extends Component{ constructor(props){ super(props); } render(){ return ( <div> {this.props.name} <Nav /> {this.props.children} <Foot /> </div> ) } }export default App;
App组件中这个 {this.props.name}
是通过外面参数传递进来的,但是上面的代码中怎么向App传递参数呢;
如果是单纯的渲染App可以这样写:
render( <App {...props}/>, ele)
希望有知道的朋友帮忙解答一下啊
相关分类