1. router切换时页面滚动没有置顶
    1. class Home extends Component {
    2. render() {
    3. <div ref={node => this.node = node}></div>
    4. }
    5. componentDidMount() {
    6. this.node.scrollIntoView()
    7. }
    8. }
    1. Route组件向component传递props
    1. <BrowserRouter basename='/hybrid/api/layout/freeShare'>
    2. <AuthRoute path='/' authInfo={authInfo}>
    3. <Switch>
    4. <Route path='/index'><ShareHome authInfo={authInfo} /></Route>
    5. <Route path='/myReceived' component={MyJoin}></Route>
    6. <Route path='/detail/1' component={ShareSubject}></Route>
    7. <Route path='/detail/0' component={ShareVip}></Route>
    8. <Route path='/receivedPage' component={Success}></Route>
    9. <Route path='/qrcode/0' component={VipLanding}></Route>
    10. <Route path='/qrcode/1' component={ShareSubject}></Route>
    11. </Switch>
    12. </AuthRoute>
    13. </BrowserRouter>
    1. 在jsx中使用node模块时
    1. //这样才能生效
    2. var fs = window.require('fs')
    3. //不生效
    4. var path = require('path')
    1. 自定义选择子组件挂载节点

    Portals 允许将组件渲染到父节点之外的 DOM 节点中。

    1. render() {
    2. return ReactDOM.createPortal(
    3. this.props.children,
    4. anyDomNode,
    5. );
    6. }