React [Umi] history(API) 路由监听

路由跳转

import { history } from 'umi';

// 跳转到指定路由
history.push('/welcome')

// 带参数跳转到指定路由
history.push('/welcome?title=value')
history.push({
    pathname: '/welcome',
    query: {
        title: 'value'
    }
})

// 跳转到上一个路由
history.goBack();

路由监听

componentDidMount() {
    history.listen((location, action) => {
      console.log(location.query)
    })
  }

版权声明:本文为weixin_45774972原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。