zoukankan      html  css  js  c++  java
  • 编程式导航

    react-router-dom中通过history对象中的push/replace/go等方法实现编程式导航功能

    this.props.history.push(path)

    this.props.history.push({

    pathname:’’,

    search:’’,

    state:{}

    })

    # 路由监听

    App.jsx组件中可以添加路由监听

    constructor(props) {

        super(props);

        this.props.history.listen(route=>console.log(route))

    }

    注:一定要在当前组件中的props中能得到路由对象才可以

    路由监听

    注:默认App.jsx组件中没有this.props.history方法,需要通过withRouter高阶组件来进行包裹,才能得到。

    右侧打赏一下 代码改变世界一块二块也是爱
  • 相关阅读:
    Rx
    linux rpm 安装包制作
    kamctl start
    dedicated bearer
    Kamailio
    EPC sequence
    TD-LTE技术原理与系统设计
    SS7
    SCTP
    GTP
  • 原文地址:https://www.cnblogs.com/ht955/p/14830979.html
Copyright © 2011-2022 走看看