router.config.js
中路由的基础设置
{
path: '/hello',
icon: 'block',
name: 'Hello',
Routes: ['src/pages/Authorized'],
authority: ['free', 'vip'],
routes: [
{
path: '/hello/a',
name: '页面a',
component: './Hello/PageA',
},
{
path: '/hello/b',
name: '页面b',
component: './Hello/PageB',
},
],
},
路由跳转 | 路由传值
window.open(`/home/...?name='liu'&&age=23`)
umi 自带的路由跳转
import Link form 'umi/link'
<Link to="/hello/world" target="blank">点击跳转</Link>
import { router } from 'umi'
router.push(url)
重定向路由
{
path: '/hello',
name: 'hello',
component: './Hello',
routes: [
{
path: '/hello',
redirect: '/hello/world_1',
},
{
path: '/hello/world_1',
component: './Hello/World1',
},
{
path: '/hello/world_2',
component: './Hello/World2',
},
],
}
页面获取路由信息
history.location.pathname
history.location.query
const { location, match } = this.props
location.pathname
match.path