var routeMap = {
"/login": Login,
"/place": Place,
"/article": Arcticle
};
function initBar(url){
if(document.getElementById('bar')){
ReactDOM.unmountComponentAtNode(document.getElementById('bar'));
}
var Bar;
if(url=="/login"){
Bar = null;
}else{
Bar = <NavBar items={itemArray} />;
}
if(Bar){
ReactDOM.render(
<div>
{Bar}
</div>,
document.getElementById('bar')
)
}
}
ReactDOM.render(
// <h1>Hello, world!</h1>,
<div id="container">
<Router path='/' component={routeMap[url]} >
{
Object.keys(routeMap).map(function (item) {
return (
<Router path={item} component={routeMap[item]} onEnter={item}/>
)
})
}
</Router>
</div>,
document.getElementById('content')
);
&#13;
onEnter事件仅在组件初始化时起作用,当我将URL从/ login更改为/ place时,onEnter事件不起作用。如果出现问题?我正在学习自己的反应。