<el-menu>
1、router屬性,若使用router屬性menu-item的index將對應router的path屬性
2、mode,下拉菜單的模式分為horizontal和vertical兩種模式
3、background-color,background-color屬性為下拉菜單整體的背景顏色
4、text-color,text-color為下拉菜單中的文字的顏色
5、active-text-color為選中的菜單的顏色
<el-menu>標簽中可以有el-submenu和el-menu-item標簽組成
demo
<el-menu :router="true" mode="horizontal" background-color="#1c213f" text-color="#fff"> <el-submenu index="1"> <template slot="title"> <i class="el-icon-menu"></i> </template> <el-menu-item index="1-1">選項一</el-menu-item> <el-submenu index="2"> <template slot="title">選項二</template> <el-menu-item index="2-1">選項二-一</el-menu-item> </el-submenu> </el-menu>
參數 | 說明 | 類型 | 可選值 | 默認值 |
---|---|---|---|---|
mode | 模式 | string | horizontal / vertical | vertical |
collapse | 是否水平折疊收起菜單(僅在 mode 為 vertical 時可用) | boolean | — | false |
background-color | 菜單的背景色(僅支持 hex 格式) | string | — | #ffffff |
text-color | 菜單的文字顏色(僅支持 hex 格式) | string | — | #303133 |
active-text-color | 當前激活菜單的文字顏色(僅支持 hex 格式) | string | — | #409EFF |
default-active | 當前激活菜單的 index | string | — | — |
default-openeds | 當前打開的 sub-menu 的 index 的數組 | Array | — | — |
unique-opened | 是否只保持一個子菜單的展開 | boolean | — | false |
menu-trigger | 子菜單打開的觸發方式(只在 mode 為 horizontal 時有效) | string | hover / click | hover |
router | 是否使用 vue-router 的模式,啟用該模式會在激活導航時以 index 作為 path 進行路由跳轉 | boolean | — | false |
collapse-transition | 是否開啟折疊動畫 | boolean | — | true |