vue+element 點擊頁面內跳轉按鈕 導航菜單選中


<template> 
  <el-menu 
    router
    theme="dark"
    :default-active="activeIndex"
    class="el-menu-demo"
    active-text-color="rgb(250,83,83)"
    mode="horizontal"
    @select="handleSelect"
  >
    <el-menu-item index="/">首頁</el-menu-item> 
    <el-menu-item index="/Material"  >我要找</el-menu-item>
    <el-menu-item index="/Workbench" >工作台</el-menu-item>
  </el-menu> 
</template>
<script>
export default {
  data() {
    return {
      activeIndex: this.$route.path
    };
  },

  watch:{
    '$route'(to,from){
      this.activeIndex=to.path
    }
  },
  mounted(){

  },
  methods: { 
    handleSelect(key, keyPath) {
    }
  }
};
</script>

 


免責聲明!

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



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