mirror of https://github.com/ElemeFE/element
				
				
				
			Menu: add support for el-menu-item without index (#13298)
							parent
							
								
									dc83a5a848
								
							
						
					
					
						commit
						57f3960927
					
				| 
						 | 
				
			
			@ -341,7 +341,7 @@ Vertical NavMenu could be collapsed.
 | 
			
		|||
### Menu-Item Attribute
 | 
			
		||||
| Attribute      | Description          | Type      | Accepted Values       | Default  |
 | 
			
		||||
|---------- |-------- |---------- |-------------  |-------- |
 | 
			
		||||
| index     | unique identification   | string  | — | — |
 | 
			
		||||
| index     | unique identification   | string/null  | — | null |
 | 
			
		||||
| route     | Vue Router object   | object | — | — |
 | 
			
		||||
| disabled | whether disabled | boolean | — | false |
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -333,7 +333,7 @@ NavMenu vertical puede ser colapsado.
 | 
			
		|||
### Atributos SubMenu 
 | 
			
		||||
| Atributo     | Descripción                              | Tipo   | Valores aceptados | Por defecto |
 | 
			
		||||
| ------------ | ---------------------------------------- | ------ | ----------------- | ----------- |
 | 
			
		||||
| index        | identificador único                      | string | —                 | —           |
 | 
			
		||||
| index        | identificador único                      | string/null | —            | null        |
 | 
			
		||||
| popper-class | nombre personalizado de la clase del menu popup | string | —                 | —           |
 | 
			
		||||
| show-timeout | tiempo de espera antes de mostrar un submenú | number | —                 | 300         |
 | 
			
		||||
| hide-timeout | tiempo de espera antes de ocultar un submenú | number | —                 | 300         |
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -347,7 +347,7 @@ Le menu vertical peut être réduit.
 | 
			
		|||
 | 
			
		||||
| Attributs      | Description          | Type      | Valeurs acceptées       | Défaut  |
 | 
			
		||||
|---------- |-------- |---------- |-------------  |-------- |
 | 
			
		||||
| index     | Identificateur unique. | string  | — | — |
 | 
			
		||||
| index     | Identificateur unique. | string/null  | — | null |
 | 
			
		||||
| route     | Objet Vue Router. | object | — | — |
 | 
			
		||||
| disabled | Si l'item est désactivé. | boolean | — | false |
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -327,7 +327,7 @@
 | 
			
		|||
### SubMenu Attribute
 | 
			
		||||
| 参数      | 说明    | 类型      | 可选值       | 默认值   |
 | 
			
		||||
|---------- |-------- |---------- |-------------  |-------- |
 | 
			
		||||
| index     | 唯一标志   | string  | — | — |
 | 
			
		||||
| index     | 唯一标志   | string/null  | — | null |
 | 
			
		||||
| popper-class | 弹出菜单的自定义类名 | string | — | — |
 | 
			
		||||
| show-timeout | 展开 sub-menu 的延时 | number | — | 300 |
 | 
			
		||||
| hide-timeout | 收起 sub-menu 的延时 | number | — | 300 |
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -44,8 +44,8 @@
 | 
			
		|||
 | 
			
		||||
    props: {
 | 
			
		||||
      index: {
 | 
			
		||||
        type: String,
 | 
			
		||||
        required: true
 | 
			
		||||
        default: null,
 | 
			
		||||
        validator: val => typeof val === 'string' || val === null
 | 
			
		||||
      },
 | 
			
		||||
      route: [String, Object],
 | 
			
		||||
      disabled: Boolean
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -251,15 +251,19 @@
 | 
			
		|||
      handleItemClick(item) {
 | 
			
		||||
        const { index, indexPath } = item;
 | 
			
		||||
        const oldActiveIndex = this.activeIndex;
 | 
			
		||||
        const hasIndex = item.index !== null;
 | 
			
		||||
 | 
			
		||||
        if (hasIndex) {
 | 
			
		||||
          this.activeIndex = item.index;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        this.activeIndex = item.index;
 | 
			
		||||
        this.$emit('select', index, indexPath, item);
 | 
			
		||||
 | 
			
		||||
        if (this.mode === 'horizontal' || this.collapse) {
 | 
			
		||||
          this.openedMenus = [];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (this.router) {
 | 
			
		||||
        if (this.router && hasIndex) {
 | 
			
		||||
          this.routeToItem(item, (error) => {
 | 
			
		||||
            this.activeIndex = oldActiveIndex;
 | 
			
		||||
            if (error) console.error(error);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,7 +3,7 @@ import { ElementUIComponent } from './component'
 | 
			
		|||
/** Submenu Component */
 | 
			
		||||
export declare class ElSubmenu extends ElementUIComponent {
 | 
			
		||||
  /** Unique identification */
 | 
			
		||||
  index: string
 | 
			
		||||
  index: string | null
 | 
			
		||||
 | 
			
		||||
  /** Delay time before showing a sub-menu */
 | 
			
		||||
  showTimeout: number
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue