- router切换时页面滚动没有置顶
class Home extends Component {
render() {
<div ref={node => this.node = node}></div>
}
componentDidMount() {
this.node.scrollIntoView()
}
}
- Route组件向component传递props
<BrowserRouter basename='/hybrid/api/layout/freeShare'>
<AuthRoute path='/' authInfo={authInfo}>
<Switch>
<Route path='/index'><ShareHome authInfo={authInfo} /></Route>
<Route path='/myReceived' component={MyJoin}></Route>
<Route path='/detail/1' component={ShareSubject}></Route>
<Route path='/detail/0' component={ShareVip}></Route>
<Route path='/receivedPage' component={Success}></Route>
<Route path='/qrcode/0' component={VipLanding}></Route>
<Route path='/qrcode/1' component={ShareSubject}></Route>
</Switch>
</AuthRoute>
</BrowserRouter>
- 在jsx中使用node模块时
//这样才能生效
var fs = window.require('fs')
//不生效
var path = require('path')
- 自定义选择子组件挂载节点
Portals 允许将组件渲染到父节点之外的 DOM 节点中。
render() {
return ReactDOM.createPortal(
this.props.children,
anyDomNode,
);
}