1.要實現路由跳轉,先要在el-menu標簽上添加router屬性,然后只要在每個el-menu-item標簽內的index屬性設置一下url即可實現點擊el-menu-item實現路由跳轉。
2.導航當前項,在el-menu標簽中綁定 :default-active="$route.path",注意是綁定屬性,不要忘了加“:”,當$route.path等於el-menu-item標簽中的index屬性值時則該item為當前項。
<el-menu :default-active="$route.path" :collapse="isCollapse" :background-color="variables.menuBg" :text-color="variables.menuText" :active-text-color="variables.menuActiveText" :unique-opened="false" :collapse-transition="false" router mode="vertical" > ...... </el-menu>
<el-menu-item :index="path" // vue得route對象里的path > ...... </el-menu-item>
轉載:https://blog.csdn.net/qq_37281252/article/details/78460159