vue 使用element 刷新保持當前路由狀態


<el-menu
        :default-active="$route.path"
        @open="handleOpen"
        @close="handleClose"
        background-color="rgb(13,20,27)"
        text-color="#fff"
        active-text-color="rgb(0,236,228)"
        router
      >
        <el-menu-item index="/WaterSourceManage/WaterSourceProfile">
          <i class="el-icon-setting"></i>
          <span slot="title">111</span>
        </el-menu-item>
<el-menu>

   (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為當前項。


免責聲明!

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



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