记录 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>