Navigation bar page, key code:
1. To achieve routing jump, first add the router attribute to the el-menu tag, and then just set the url in the index attribute of each el-menu-item tag to realize the routing jump by clicking el-menu-item change.
2. To navigate the current item, bind in the el-menu tag: default-active="$route.path", pay attention to the binding attribute, don't forget to add ":", when $route.path is equal to el-menu- The item is the current item when the index attribute value in the item tag.
The specific usage of vue-router can refer to:
code:
<div class="nav-list-box">
<h1 @click="goHome">xxx后台管理系统</h1>
<el-menu
router
:default-active="$route.path"
class="el-menu-vertical"
@open="handleOpen"
@close="handleClose"
:collapse="isCollapse"
background-color="#545c64"
text-color="#fff"
active-text-color="#ffd04b">
<el-menu-item index="/daohang1">
<i class="el-icon-s-management"></i>
<span slot="title">导航1</span>
</el-menu-item>
<el-menu-item index="/daohang2">
<i class="el-icon-menu"></i>
<span slot="title">导航2</span>
</el-menu-item>
<el-menu-item index="/daohang3">
<i class="el-icon-document"></i>
<span slot="title">导航3</span>
</el-menu-item>
<el-menu-item index="/daohang4">
<i class="el-icon-setting"></i>
<span slot="title">导航4</span>
</el-menu-item>
</el-menu>
</div>
reference: