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>
原文地址:https://www.cnblogs.com/aknife/p/12503616.html