fix(components):[time-picker] add parseFloat to resolve TimePicker offset (#12837)

* fix(components): add parseFloat to resolve TimePicker offset

Height is calculated using offsetHeight, offsetHeight will be rounded off

closed #12835

* fix(components): import getStyle to optimize the code

closed #12835

* Delete useless statements

* add judgment

* Update basic-time-spinner.vue
This commit is contained in:
20savage
2023-06-04 10:49:48 +08:00
committed by GitHub
parent cb01089128
commit 3853845fc9

View File

@@ -85,6 +85,7 @@ import ElScrollbar from '@element-plus/components/scrollbar'
import ElIcon from '@element-plus/components/icon'
import { ArrowDown, ArrowUp } from '@element-plus/icons-vue'
import { useNamespace } from '@element-plus/hooks'
import { getStyle } from '@element-plus/utils'
import { timeUnits } from '../constants'
import { buildTimeList } from '../utils'
import { basicTimeSpinnerProps } from '../props/basic-time-spinner'
@@ -212,7 +213,11 @@ const adjustSpinner = (type: TimeUnit, value: number) => {
const typeItemHeight = (type: TimeUnit): number => {
const scrollbar = unref(listRefsMap[type])
return scrollbar?.$el.querySelector('li').offsetHeight || 0
const listItem = scrollbar?.$el.querySelector('li')
if (listItem) {
return Number.parseFloat(getStyle(listItem, 'height')) || 0
}
return 0
}
const onIncrement = () => {