router-link 高亮
时间: 2023-09-13 08:08:38 浏览: 104
详解angular路由高亮之RouterLinkActive
在Vue Router中,router-link可以通过添加类名来实现高亮效果。默认情况下,当路由匹配当前路径时,router-link会添加router-link-exact-active和router-link-active类。你可以通过在路由规则配置中使用linkActiveClass来修改router-link-active类名。例如,你可以在main.js(或router.js)中添加以下代码:
const router = new VueRouter({
routes: [
// 路由规则配置
],
linkActiveClass: 'custom-active' // 自定义的类名
})
这样,当路由匹配到当前路径时,router-link会添加custom-active类名,从而实现高亮效果。注意,你可以将custom-active替换为你想要的任何类名。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [router-link进行高亮设置:全局配置linkActivateClass](https://blog.csdn.net/weixin_44343544/article/details/113726767)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [Vue-路由导航菜单栏的高亮设置方法](https://download.csdn.net/download/weixin_38586279/14902227)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [如何给router-link进行高亮设置——全局配置linkActiveClass](https://blog.csdn.net/qq_36836277/article/details/97806643)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文