[bugfix] Tab: 修复极端情况激活态异常

This commit is contained in:
rex 2019-08-15 15:58:19 +08:00 committed by GitHub
parent 5addfd8526
commit e5945c5459
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 11 deletions

View File

@ -1,23 +1,22 @@
function isDef(value: any): boolean { export function isDef(value: any): boolean {
return value !== undefined && value !== null; return value !== undefined && value !== null;
} }
function isObj(x: any): boolean { export function isObj(x: any): boolean {
const type = typeof x; const type = typeof x;
return x !== null && (type === 'object' || type === 'function'); return x !== null && (type === 'object' || type === 'function');
} }
function isNumber(value) { export function isNumber(value) {
return /^\d+$/.test(value); return /^\d+$/.test(value);
} }
function range(num: number, min: number, max: number) { export function range(num: number, min: number, max: number) {
return Math.min(Math.max(num, min), max); return Math.min(Math.max(num, min), max);
} }
export { export function nextTick(fn: Function) {
isObj, setTimeout(() => {
isDef, fn();
isNumber, }, 1000 / 30);
range }
};

View File

@ -1,6 +1,7 @@
import { VantComponent } from '../common/component'; import { VantComponent } from '../common/component';
import { touch } from '../mixins/touch'; import { touch } from '../mixins/touch';
import { Weapp } from 'definitions/weapp'; import { Weapp } from 'definitions/weapp';
import { nextTick } from '../common/utils';
type TabItemData = { type TabItemData = {
width?: number width?: number
@ -236,7 +237,7 @@ VantComponent({
} }
}); });
this.set({}, () => { nextTick(() => {
this.setLine(); this.setLine();
this.setTrack(); this.setTrack();
this.scrollIntoView(); this.scrollIntoView();