1. 作用:可以简化路由的跳转
2. 如何使用
// 1.给路由命名
{
path: '/demo',
component: Demo,
children:[
{
path: '/test',
component: Test,
children:[
{
name: 'hello', //给路由命名
path: 'welcome',
component: Hello
}
]
}
]
}
// 2.简化跳转
//简化前,需要写完整的路径
<router-link to="demo/test/welcome">跳转</router-link>
//简化后,直接通过名字跳转
<router-link :to="{name: 'hello'}">跳转</router-link>
//简化写法配合传递参数
<router-link
:to="{
name: 'hello',
query: {
id: m.id,
title: m.title
}
}">跳转
</router-link>