mirror of
https://gitee.com/ElemeFE/element.git
synced 2024-11-29 18:57:36 +08:00
Tabs: add activeName and oldActiveName parameters to before-leave hook (#11713)
* Tabs: add activeName and oldActiveName parameters to before-leave hook * Tabs: fix docs
This commit is contained in:
parent
8397e12d1a
commit
ef98b75aff
@ -377,7 +377,7 @@ Only card type Tabs support addable & closeable.
|
||||
| value | name of the selected tab | string | — | name of first tab |
|
||||
| tab-position | position of tabs | string | top/right/bottom/left | top |
|
||||
| stretch | whether width of tab automatically fits its container | boolean | - | false |
|
||||
| before-leave | hook function before switching tab. If `false` is returned or a `Promise` is returned and then is rejected, switching will be prevented | function | — | — |
|
||||
| before-leave | hook function before switching tab. If `false` is returned or a `Promise` is returned and then is rejected, switching will be prevented | Function(activeName, oldActiveName) | — | — |
|
||||
|
||||
### Tabs Events
|
||||
| Event Name | Description | Parameters |
|
||||
|
@ -377,7 +377,7 @@ Solo las pestañas de tipo tarjeta soportan adición y cierre.
|
||||
| value | nombre de la pestaña seleccionada | string | — | nombre de la primer pestaña |
|
||||
| tab-position | posición de tabulación | string | top/right/bottom/left | top |
|
||||
| stretch | si el ancho del tab se ajusta automáticamente a su contenedor | boolean | - | false |
|
||||
| before-leave | función `hook` antes de cambiar de pestaña. Si se devuelve `false` o se devuelve una `Promise` y luego se rechaza, se evitará el cambio. | function | — | — |
|
||||
| before-leave | función `hook` antes de cambiar de pestaña. Si se devuelve `false` o se devuelve una `Promise` y luego se rechaza, se evitará el cambio. | Function(activeName, oldActiveName) | — | — |
|
||||
|
||||
### Eventos de Pestañas
|
||||
| Nombre de Evento | Descripción | Parámetros |
|
||||
|
@ -375,7 +375,7 @@
|
||||
| value | 绑定值,选中选项卡的 name | string | — | 第一个选项卡的 name |
|
||||
| tab-position | 选项卡所在位置 | string | top/right/bottom/left | top |
|
||||
| stretch | 标签的宽度是否自撑开 | boolean | - | false |
|
||||
| before-leave | 切换标签之前的钩子,若返回 false 或者返回 Promise 且被 reject,则阻止切换。 | function | — | — |
|
||||
| before-leave | 切换标签之前的钩子,若返回 false 或者返回 Promise 且被 reject,则阻止切换。 | Function(activeName, oldActiveName) | — | — |
|
||||
|
||||
### Tabs Events
|
||||
| 事件名称 | 说明 | 回调参数 |
|
||||
|
@ -74,7 +74,7 @@
|
||||
this.$emit('input', value);
|
||||
};
|
||||
if (this.currentName !== value && this.beforeLeave) {
|
||||
const before = this.beforeLeave();
|
||||
const before = this.beforeLeave(value, this.currentName);
|
||||
if (before && before.then) {
|
||||
before.then(() => {
|
||||
changeCurrentName();
|
||||
|
2
types/tabs.d.ts
vendored
2
types/tabs.d.ts
vendored
@ -27,5 +27,5 @@ export declare class ElTabs extends ElementUIComponent {
|
||||
stretch: Boolean
|
||||
|
||||
/** Hook function before switching tab. If false or a Promise is returned and then is rejected, switching will be prevented */
|
||||
beforeLeave: () => boolean | Promise<any>
|
||||
beforeLeave: (activeName: string, oldActiveName: string) => boolean | Promise<any>
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user