主要是element中el-menu中的属性::default-active="$route.path" 其中path是在router.js中设置的rotes的属性值
<el-menu
default-active="2"
class="el-menu-vertical-demo"
background-color="#2f4050"
text-color="#fff"
active-text-color="#fff"
router
:default-active="$route.path"
>
</el-menu>
例如:
{
path:'cate',
component:Cate,
name:'分类',
meta:{title:'管理-分类'}
},