From be3a3ed699f73d352d49623ef07288093a3332c4 Mon Sep 17 00:00:00 2001 From: vben <anncwb@126.com> Date: 星期一, 22 二月 2021 00:01:03 +0800 Subject: [PATCH] perf: remove useless code --- src/components/VirtualScroll/src/index.tsx | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/src/components/VirtualScroll/src/index.tsx b/src/components/VirtualScroll/src/index.tsx index 1e17ee6..2f82723 100644 --- a/src/components/VirtualScroll/src/index.tsx +++ b/src/components/VirtualScroll/src/index.tsx @@ -11,12 +11,22 @@ } from 'vue'; import { useEventListener } from '/@/hooks/event/useEventListener'; -import { convertToUnit } from '/@/components/util'; import { props as basicProps } from './props'; import { getSlot } from '/@/utils/helper/tsxHelper'; import './index.less'; const prefixCls = 'virtual-scroll'; + +function convertToUnit(str: string | number | null | undefined, unit = 'px'): string | undefined { + if (str == null || str === '') { + return undefined; + } else if (isNaN(+str!)) { + return String(str); + } else { + return `${Number(str)}${unit}`; + } +} + export default defineComponent({ name: 'VirtualScroll', props: basicProps, -- Gitblit v1.8.0