item | desc |
---|---|
to | 当点击该链接时应该进入的路由地址
使用 to 属性代替 href 属性 |
replace | 默认是 push 模式,浏览器可以回退
使用 replace 属性可以防止浏览器回退 |
activeClass | 链接在匹配当前路由时被应用到 class |
exactActiveClass | 链接在严格匹配当前路由时被应用到 class
多用于嵌套路由中 |
<router-link to = "/home" >home</router-link> <router-link to = "/team" >team</router-link> <router-link to = "/about" replace >about</router-link>
<router-link to = "/work/html" >html</router-link> <router-link to = "/work/css3" >css3</router-link> <router-link to = "/work/js" >js</router-link>
{ path: '/', name: 'home', components: { default: () => import('../views/Home.vue'), aside: () => import('../components/Aside.vue'), header: () => import('../components/Header.vue'), main: () => import('../components/Main.vue'), } }
<router-view name="aside"></router-view> <router-view name="header"></router-view> <router-view name="main"></router-view>
.to
.replace
.activeClass
.exactActiveClass
<a href="/">home</a> <a href="/menu">menu</a> <a href="/mall>mall</a> <a href="/vip"&vipout</a> <a href="/mine"&mineout</a>