美文网首页
21. withRouter

21. withRouter

作者: dwy_interesting | 来源:发表于2018-11-09 14:58 被阅读0次

withRouter 你可以通过 withRouter 高阶组件访问 history 对象的属性和最近(UI 结构上靠的最近)的 <Route> 的 match 对象。当组件渲染时,withRouter 会将更新后的 match、location 和 history 传递给它。封装组件的所有无反应的特定静态方法和属性都会自动复制到 connected 组件。
Component.WrappedComponent 被包装的组件被公开为返回组件上的静态属性 WrappedComponent,它可用于隔离测试组件等等。
wrappedComponentRef: func 一个将作为 ref 属性传递给包装组件的函数

高阶组件的使用

image.png

高阶组件withRouter工作原理

image.png

相关文章

网友评论

      本文标题:21. withRouter

      本文链接:https://www.haomeiwen.com/subject/qjawxqtx.html