Tabs add prop beforeRemove, close #4379
This commit is contained in:
parent
cec470ebd5
commit
753720d9bd
2 changed files with 34 additions and 196 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue