Tabs add prop beforeRemove, close #4379

This commit is contained in:
梁灏 2018-08-29 14:37:45 +08:00
parent cec470ebd5
commit 753720d9bd
2 changed files with 34 additions and 196 deletions

View file

@ -91,7 +91,8 @@
closable: {
type: Boolean,
default: false
}
},
beforeRemove: Function,
},
data () {
return {
@ -247,6 +248,21 @@
this.handleChange(index);
},
handleRemove (index) {
if (!this.beforeRemove) {
return this.handleRemoveTab(index);
}
const before = this.beforeRemove(index);
if (before && before.then) {
before.then(() => {
this.handleRemoveTab(index);
});
} else {
this.handleRemoveTab(index);
}
},
handleRemoveTab (index) {
const tabs = this.getTabs();
const tab = tabs[index];
tab.$destroy();