diff --git a/src/base/combination/tab.js b/src/base/combination/tab.js index 664b0c09a..06a9a06fd 100644 --- a/src/base/combination/tab.js +++ b/src/base/combination/tab.js @@ -15,7 +15,8 @@ BI.Tab = BI.inherit(BI.Widget, { tab: false, cardCreator: function (v) { return BI.createWidget(); - } + }, + keepAlives: [] }); }, @@ -60,7 +61,7 @@ BI.Tab = BI.inherit(BI.Widget, { var self = this, o = this.options; if (o.single === true) { BI.each(this.cardMap, function (name, card) { - if (name !== (currCardName + "")) { + if (name !== (currCardName + "") && self._keepAlive(name) !== true) { self.layout.deleteCardByName(name); delete self.cardMap[name]; } @@ -76,6 +77,12 @@ BI.Tab = BI.inherit(BI.Widget, { } }, + _keepAlive: function (v) { + var o = this.options; + var keepAlives = BI.isFunction(o.keepAlives) ? o.keepAlives() : o.keepAlives; + return BI.contains(keepAlives, v); + }, + created: function () { var o = this.options; if (o.showIndex !== false) { diff --git a/typescript/base/combination/tab.ts b/typescript/base/combination/tab.ts index 611c3e9c0..fa4cc8b25 100644 --- a/typescript/base/combination/tab.ts +++ b/typescript/base/combination/tab.ts @@ -15,6 +15,7 @@ export declare class Tab extends Widget { dynamic: boolean; }; tab?: Obj; + keepAlives?: string[] | ((cardName: string) => boolean) } setSelect(v: string | number, action?: Action, callback?: Function): void;