dva路由跳转

xiaoxiao2021-02-28  51

在dva中我们要想实现路由跳转,可以使用官方提供的一个叫做routerRedux的包来实现,用法如下面

 

import { routerRedux } from 'dva/router' dispatch(routerRedux.push(loaction))

 

上面的location应该都知道,是浏览器的history里面的一个属性,记录了当前路由的一些信息, 例如pathname, query, search state等属性,当我们要跳转路由的时候,将指定location对象里面的pathname即可,例如

import { routerRedux } from 'dva/router' dispatch(routerRedux.push({ pathname: 'info/detail' }))

然后就会自动跳转。

 

转载请注明原文地址: https://www.6miu.com/read-2150388.html

最新回复(0)