diff --git a/packages/common/utils.ts b/packages/common/utils.ts index 9fe49709..1256a476 100644 --- a/packages/common/utils.ts +++ b/packages/common/utils.ts @@ -1,6 +1,8 @@ import { isDef, isNumber, isPlainObject, isPromise } from './validator'; import { canIUseGroupSetData, canIUseNextTick } from './version'; +export { isDef } from './validator'; + export function range(num: number, min: number, max: number) { return Math.min(Math.max(num, min), max); } diff --git a/packages/index-bar/index.ts b/packages/index-bar/index.ts index c7b623e0..6ec0274c 100644 --- a/packages/index-bar/index.ts +++ b/packages/index-bar/index.ts @@ -1,7 +1,7 @@ import { GREEN } from '../common/color'; import { VantComponent } from '../common/component'; import { useChildren } from '../common/relation'; -import { getRect } from '../common/utils'; +import { getRect, isDef } from '../common/utils'; import { pageScrollMixin } from '../mixins/page-scroll'; const indexList = () => { @@ -110,6 +110,9 @@ VantComponent({ setSiderbarRect() { return getRect(this, '.van-index-bar__sidebar').then((res) => { + if (!isDef(res)) { + return; + } this.sidebar = { height: res.height, top: res.top,