document.write("");

记录 vue3 el-menu 与vue-router 关联

 

<template>
  <el-menu :default-active="activeMenu" router>
    <el-menu-item index="/home">首页</el-menu-item>
    <el-menu-item index="/about">关于我们</el-menu-item>
    <el-menu-item index="/contact">联系我们</el-menu-item>
  </el-menu>
  <router-view />
</template>
 
<script setup>
import { computed } from 'vue';
import { useRoute } from 'vue-router';
 
const route = useRoute();
 
const activeMenu = computed(() => route.path);
</script>

  

posted @ 2024-03-08 14:28  人间春风意  阅读(14)  评论(0)    收藏  举报