vue + el-menu(Element-UI)之路由跳轉


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM