Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tabs: add activeName and oldActiveName parameters to before-leave hook #11713

Merged
merged 2 commits into from
Jun 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/docs/en-US/tabs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
2 changes: 1 addition & 1 deletion examples/docs/es/tabs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
2 changes: 1 addition & 1 deletion examples/docs/zh-CN/tabs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
| 事件名称 | 说明 | 回调参数 |
Expand Down
2 changes: 1 addition & 1 deletion packages/tabs/src/tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion types/tabs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

参数顺序好像反了

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

或者上面的参数顺序调一下吧

}