首先要在el-menu标签上添加:default-openeds="openeds"属性,并且在data里面定义,定义的是每一个index的值
<el-menu default-active="3"
class="el-menu-vertical-demo"
:default-openeds="openeds"
@open="handleOpen"
@close="handleClose">
data() {
return {
scrollHeight: '0px',
openeds: ['1', '2', '3'],//默认展开导航栏
}
}