0
我想每个反应组件都有多个RouteHandler。这可能吗?我如何让我的路由器知道每个路由分配给哪个RouteHandler?相同组件上的React-Router多个RouteHandlers
就是这样。 (下面的代码什么也不做 - 只是为了证明我想要的)
import React from 'react'
import { RouteHandler } from 'react-router'
import { _, div } from 'factories'
export default
class dummy extends React.Component {
constructor() {
super();
this.state = {}
}
componentWillMount() {
}
componentWillUnmount() {
}
render() {
return (
div({},
_(RouteHandler)({route: 'players'}), // if the url is players, this handler is used
_(RouteHandler)({route: 'add'}) // if the url is add, this handler is used
)
)
}
}
dummy.contextTypes = {
router: React.PropTypes.func
};
中那么,你是通过组件的道具,而不是使用路径处理程序? –