2017-11-06 19:22:02 +08:00
## NavMenu
2017-11-11 15:32:35 +08:00
Menú que provee la navegación para tu sitio.
2017-11-06 19:22:02 +08:00
### Top bar
2017-11-11 15:32:35 +08:00
Top bar NavMenu puede ser usado en distinto escenarios.
2017-12-12 12:45:09 +08:00
:::demo Por defecto el menú es vertical, pero puede hacerlo horizontal asignando a la propiedad `mode` el valor 'horizontal'. Además, puede utilizar el componente de submenú para crear un menú de segundo nivel. Menú provee `background-color` , `text-color` y `active-text-color` para customizar los colores.
2017-11-06 19:22:02 +08:00
```html
< el-menu :default-active = "activeIndex" class = "el-menu-demo" mode = "horizontal" @select =" handleSelect " >
< el-menu-item index = "1" > Processing Center< / el-menu-item >
2018-01-08 13:38:51 +08:00
< el-submenu index = "2" >
2017-11-06 19:22:02 +08:00
< template slot = "title" > Workspace< / template >
< el-menu-item index = "2-1" > item one< / el-menu-item >
< el-menu-item index = "2-2" > item two< / el-menu-item >
< el-menu-item index = "2-3" > item three< / el-menu-item >
2018-02-09 12:14:35 +08:00
< el-submenu index = "2-4" >
< template slot = "title" > item four< / template >
< el-menu-item index = "2-4-1" > item one< / el-menu-item >
< el-menu-item index = "2-4-2" > item two< / el-menu-item >
< el-menu-item index = "2-4-3" > item three< / el-menu-item >
< / el-submenu >
2017-11-06 19:22:02 +08:00
< / el-submenu >
2018-02-11 14:59:46 +08:00
< el-menu-item index = "3" disabled > Info< / el-menu-item >
< el-menu-item index = "4" > < a href = "https://www.ele.me" target = "_blank" > Orders< / a > < / el-menu-item >
2017-11-06 19:22:02 +08:00
< / el-menu >
< div class = "line" > < / div >
< el-menu
:default-active="activeIndex2"
class="el-menu-demo"
mode="horizontal"
@select ="handleSelect"
background-color="#545c64"
text-color="#fff"
active-text-color="#ffd04b">
< el-menu-item index = "1" > Processing Center< / el-menu-item >
< el-submenu index = "2" >
< template slot = "title" > Workspace< / template >
< el-menu-item index = "2-1" > item one< / el-menu-item >
< el-menu-item index = "2-2" > item two< / el-menu-item >
< el-menu-item index = "2-3" > item three< / el-menu-item >
2018-02-09 12:14:35 +08:00
< el-submenu index = "2-4" >
< template slot = "title" > item four< / template >
< el-menu-item index = "2-4-1" > item one< / el-menu-item >
< el-menu-item index = "2-4-2" > item two< / el-menu-item >
< el-menu-item index = "2-4-3" > item three< / el-menu-item >
< / el-submenu >
2017-11-06 19:22:02 +08:00
< / el-submenu >
2018-02-11 14:59:46 +08:00
< el-menu-item index = "3" disabled > Info< / el-menu-item >
< el-menu-item index = "4" > < a href = "https://www.ele.me" target = "_blank" > Orders< / a > < / el-menu-item >
2017-11-06 19:22:02 +08:00
< / el-menu >
< script >
export default {
data() {
return {
activeIndex: '1',
activeIndex2: '1'
};
},
methods: {
handleSelect(key, keyPath) {
console.log(key, keyPath);
}
}
}
< / script >
```
:::
### Side bar
2017-11-11 15:32:35 +08:00
NavMenu vertical con sub-menús.
2017-12-12 12:45:09 +08:00
:::demo Puede utilizar el componente `el-menu-item-group` para crear un grupo de menú, y el nombre del grupo estará determinado por la propiedad `title` o la propiedad `slot` .
2017-11-06 19:22:02 +08:00
```html
< el-row class = "tac" >
< el-col :span = "12" >
< h5 > Default colors< / h5 >
< el-menu
default-active="2"
class="el-menu-vertical-demo"
@open ="handleOpen"
@close ="handleClose">
< el-submenu index = "1" >
< template slot = "title" >
< i class = "el-icon-location" > < / i >
< span > Navigator One< / span >
< / template >
< el-menu-item-group title = "Group One" >
< el-menu-item index = "1-1" > item one< / el-menu-item >
< el-menu-item index = "1-2" > item one< / el-menu-item >
< / el-menu-item-group >
< el-menu-item-group title = "Group Two" >
< el-menu-item index = "1-3" > item three< / el-menu-item >
< / el-menu-item-group >
< el-submenu index = "1-4" >
< template slot = "title" > item four< / template >
< el-menu-item index = "1-4-1" > item one< / el-menu-item >
< / el-submenu >
< / el-submenu >
< el-menu-item index = "2" >
< i class = "el-icon-menu" > < / i >
< span > Navigator Two< / span >
< / el-menu-item >
2018-02-11 14:59:46 +08:00
< el-menu-item index = "3" disabled >
< i class = "el-icon-document" > < / i >
2017-11-06 19:22:02 +08:00
< span > Navigator Three< / span >
< / el-menu-item >
2018-02-11 14:59:46 +08:00
< el-menu-item index = "4" >
< i class = "el-icon-setting" > < / i >
< span > Navigator Four< / span >
< / el-menu-item >
2017-11-06 19:22:02 +08:00
< / el-menu >
< / el-col >
< el-col :span = "12" >
< h5 > Custom colors< / h5 >
< el-menu
default-active="2"
class="el-menu-vertical-demo"
@open ="handleOpen"
@close ="handleClose"
background-color="#545c64"
text-color="#fff"
active-text-color="#ffd04b">
< el-submenu index = "1" >
< template slot = "title" >
< i class = "el-icon-location" > < / i >
< span > Navigator One< / span >
< / template >
< el-menu-item-group title = "Group One" >
< el-menu-item index = "1-1" > item one< / el-menu-item >
< el-menu-item index = "1-2" > item one< / el-menu-item >
< / el-menu-item-group >
< el-menu-item-group title = "Group Two" >
< el-menu-item index = "1-3" > item three< / el-menu-item >
< / el-menu-item-group >
< el-submenu index = "1-4" >
< template slot = "title" > item four< / template >
< el-menu-item index = "1-4-1" > item one< / el-menu-item >
< / el-submenu >
< / el-submenu >
< el-menu-item index = "2" >
< i class = "el-icon-menu" > < / i >
< span > Navigator Two< / span >
< / el-menu-item >
2018-02-11 14:59:46 +08:00
< el-menu-item index = "3" disabled >
< i class = "el-icon-document" > < / i >
2017-11-06 19:22:02 +08:00
< span > Navigator Three< / span >
< / el-menu-item >
2018-02-11 14:59:46 +08:00
< el-menu-item index = "4" >
< i class = "el-icon-setting" > < / i >
< span > Navigator Four< / span >
< / el-menu-item >
2017-11-06 19:22:02 +08:00
< / el-menu >
< / el-col >
< / el-row >
< script >
export default {
methods: {
handleOpen(key, keyPath) {
console.log(key, keyPath);
},
handleClose(key, keyPath) {
console.log(key, keyPath);
}
}
}
< / script >
```
:::
### Collapse
2017-11-11 15:32:35 +08:00
NavMenu vertical puede ser colapsado.
2017-11-06 19:22:02 +08:00
2017-12-12 12:45:09 +08:00
:::demo
2017-11-06 19:22:02 +08:00
```html
< el-radio-group v-model = "isCollapse" style = "margin-bottom: 20px;" >
< el-radio-button :label = "false" > expand< / el-radio-button >
< el-radio-button :label = "true" > collapse< / el-radio-button >
< / el-radio-group >
< el-menu default-active = "2" class = "el-menu-vertical-demo" @open =" handleOpen " @close =" handleClose " :collapse = "isCollapse" >
< el-submenu index = "1" >
< template slot = "title" >
< i class = "el-icon-location" > < / i >
< span slot = "title" > Navigator One< / span >
< / template >
< el-menu-item-group >
< span slot = "title" > Group One< / span >
< el-menu-item index = "1-1" > item one< / el-menu-item >
< el-menu-item index = "1-2" > item two< / el-menu-item >
< / el-menu-item-group >
< el-menu-item-group title = "Group Two" >
< el-menu-item index = "1-3" > item three< / el-menu-item >
< / el-menu-item-group >
< el-submenu index = "1-4" >
< span slot = "title" > item four< / span >
< el-menu-item index = "1-4-1" > item one< / el-menu-item >
< / el-submenu >
< / el-submenu >
< el-menu-item index = "2" >
< i class = "el-icon-menu" > < / i >
< span slot = "title" > Navigator Two< / span >
< / el-menu-item >
2018-02-11 14:59:46 +08:00
< el-menu-item index = "3" disabled >
< i class = "el-icon-document" > < / i >
2017-11-06 19:22:02 +08:00
< span slot = "title" > Navigator Three< / span >
< / el-menu-item >
2018-02-11 14:59:46 +08:00
< el-menu-item index = "4" >
< i class = "el-icon-setting" > < / i >
< span slot = "title" > Navigator Four< / span >
< / el-menu-item >
2017-11-06 19:22:02 +08:00
< / el-menu >
< style >
.el-menu-vertical-demo:not(.el-menu--collapse) {
width: 200px;
min-height: 400px;
}
< / style >
< script >
export default {
data() {
return {
isCollapse: true
};
},
methods: {
handleOpen(key, keyPath) {
console.log(key, keyPath);
},
handleClose(key, keyPath) {
console.log(key, keyPath);
}
}
}
< / script >
```
:::
2017-11-11 15:32:35 +08:00
### Atributos Menu
2017-12-03 18:03:06 +08:00
| Atributo | Descripción | Tipo | Valores aceptados | Por defecto |
| ----------------- | ---------------------------------------- | ------- | --------------------- | ----------- |
| mode | modo de presentación del menú | string | horizontal / vertical | vertical |
| collapse | si el menú está colapsado (solo en modo vertical) | boolean | — | false |
| background-color | color de fondo del menú (formato hexadecimal) | string | — | #ffffff |
2017-12-12 12:45:09 +08:00
| text-color | color de texto del menú (formato hexadecimal) | string | — | #303133 |
2017-12-03 18:03:06 +08:00
| active-text-color | color de text del menu-item activo (formato hexadecimal) | string | — | #409EFF |
| default-active | índice del menu-item activo | string | — | — |
| default-openeds | arreglo que contiene las llaves del sub-menus activo | Array | — | — |
| unique-opened | si solo un submenu puede ser activo | boolean | — | false |
2018-08-09 13:32:05 +08:00
| menu-trigger | como dispara eventos sub-menus, solo funciona cuando `mode` es 'horizontal' | string | hover / click | hover |
2017-12-03 18:03:06 +08:00
| router | si el modo `vue-router` está activado. Si es verdader, índice será usado como 'path' para activar la ruta | boolean | — | false |
2018-03-29 10:35:02 +08:00
| collapse-transition | si se debe permitir collapse transition | boolean | — | true |
2017-11-06 19:22:02 +08:00
2017-11-11 15:32:35 +08:00
### Métodos Menu
2018-10-15 18:38:57 +08:00
| Métodos de evento | Descripción | Parámetros |
2017-12-03 18:03:06 +08:00
| ---------------- | ----------------------------- | -------------------------------------- |
| open | abre un sub-menu específico | index: índice del sub-menu para abrir |
| close | cierra un sub-menu específico | index: índice del sub-menu para cerrar |
2017-11-06 19:22:02 +08:00
2017-11-11 15:32:35 +08:00
### Eventos Menu
2017-12-03 18:03:06 +08:00
| Nombre de evento | Descripción | Parámetros |
| ---------------- | ---------------------------------------- | ---------------------------------------- |
| select | callback ejecutado cuando el menú es activado | index: índice del menú activado, indexPath: index path del menú activado |
| open | callback ejecutado cuando sub-menu se expande | index: índice del sub-menu expandido, indexPath: index path del sub-menu expandido |
| close | callback ejecutado cuando sub-menu colapsa | index: índice del sub-menu colapsado, indexPath: index path del menú colapsado |
2017-11-06 19:22:02 +08:00
2017-11-11 15:32:35 +08:00
### Eventos Menu-Item
2017-12-03 18:03:06 +08:00
| Nombre de evento | Descripción | Parámetros |
| ---------------- | ---------------------------------------- | -------------------------- |
| click | callback ejecutado cuando se hace click sobre menu-item | el: instancia de menu-item |
2017-11-06 19:22:02 +08:00
2017-11-11 15:32:35 +08:00
### Atributos SubMenu
2018-01-08 17:36:31 +08:00
| Atributo | Descripción | Tipo | Valores aceptados | Por defecto |
| ------------ | ---------------------------------------- | ------ | ----------------- | ----------- |
2019-02-22 19:25:38 +08:00
| index | identificador único | string/null | — | null |
2018-02-13 10:59:24 +08:00
| popper-class | nombre personalizado de la clase del menu popup | string | — | — |
2018-01-08 17:36:31 +08:00
| show-timeout | tiempo de espera antes de mostrar un submenú | number | — | 300 |
| hide-timeout | tiempo de espera antes de ocultar un submenú | number | — | 300 |
2018-02-13 10:59:24 +08:00
| disabled | si esta `disabled` el sub-menu | boolean | — | false |
2018-04-05 20:07:03 +08:00
| popper-append-to-body | si se debe agregar el menú emergente al cuerpo. Si la posición del menú es incorrecta, puede intentar ajustar este prop | boolean | - | level one Submenu: true / other Submenus: false |
2017-11-06 19:22:02 +08:00
2017-11-11 15:32:35 +08:00
### Atributos Menu-Item
2017-12-03 18:03:06 +08:00
| Atributo | Descripción | Tipo | Valores aceptados | Por defecto |
| -------- | ------------------- | ------ | ----------------- | ----------- |
| index | identificador único | string | — | — |
| route | Objeto Vue Router | object | — | — |
2018-02-13 10:59:24 +08:00
| disabled | si esta `disabled` | boolean | — | false |
2017-11-06 19:22:02 +08:00
2017-11-11 15:32:35 +08:00
### Atributos Menu-Group
2017-12-03 18:03:06 +08:00
| Atributo | Descripción | Tipo | Valores aceptados | Por defecto |
| -------- | ---------------- | ------ | ----------------- | ----------- |
| title | título del grupo | string | — | — |