diff --git a/src/base/combination/tab.js b/src/base/combination/tab.js index 893513721..90a788a17 100644 --- a/src/base/combination/tab.js +++ b/src/base/combination/tab.js @@ -86,15 +86,18 @@ BI.Tab = BI.inherit(BI.Widget, { created: function () { var self = this, o = this.options; - if (o.showIndex !== false) { - if (BI.isFunction(o.showIndex)) { - var v = this.__watch(o.showIndex, function (context, newValue) { - self.setSelect(newValue); - }); - this.setSelect(v); - } else { - this.setSelect(o.showIndex); - } + + var showIndex; + if (BI.isFunction(o.showIndex)) { + showIndex = this.__watch(o.showIndex, function (context, newValue) { + self.setSelect(newValue); + }); + } else { + showIndex = o.showIndex; + } + + if (showIndex !== false) { + this.setSelect(showIndex); } }, @@ -135,7 +138,7 @@ BI.Tab = BI.inherit(BI.Widget, { getTab: function (v) { this._assertCard(v); -return this.layout.getCardByName(v); + return this.layout.getCardByName(v); }, setValue: function (v) { diff --git a/typescript/core/widget.ts b/typescript/core/widget.ts index 0a1b63246..4c1fc9d2f 100644 --- a/typescript/core/widget.ts +++ b/typescript/core/widget.ts @@ -42,8 +42,8 @@ export interface _Widget extends _OB { element: { width(): number; height(): number; - width(width: number | string): _Widget['element']; - height(height: number | string): _Widget['element']; + width(width: number | string): _Widget["element"]; + height(height: number | string): _Widget["element"]; [key: string]: any; }; @@ -110,7 +110,7 @@ export interface _Widget extends _OB { /** * 更新前 */ - shouldUpdate?(): void; + shouldUpdate?(...args: any[]): void; /** * 更新 @@ -449,8 +449,8 @@ export declare class Widget extends OB { element: { width(): number; height(): number; - width(width: number | string): Widget['element']; - height(height: number | string): Widget['element']; + width(width: number | string): Widget["element"]; + height(height: number | string): Widget["element"]; [key: string]: any; }; @@ -783,6 +783,11 @@ export declare class Widget extends OB { */ _unMount(): void; + /** + * watch响应式数据 + */ + __watch any>(getter: T, handler: Function, options?: Obj): ReturnType + /** * hang元素 */