refactor(components): [form-label-wrap] use getStyle method (#13913)

This commit is contained in:
tiansQAQ 2023-08-09 20:52:03 +08:00 committed by GitHub
parent ec639c4d14
commit c6a6d9bc6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,7 +11,7 @@ import {
watch,
} from 'vue'
import { useResizeObserver } from '@vueuse/core'
import { throwError } from '@element-plus/utils'
import { getStyle, throwError } from '@element-plus/utils'
import { useNamespace } from '@element-plus/hooks'
import { formContextKey, formItemContextKey } from './constants'
@ -41,8 +41,11 @@ export default defineComponent({
const getLabelWidth = () => {
if (el.value?.firstElementChild) {
const width = window.getComputedStyle(el.value.firstElementChild).width
return Math.ceil(Number.parseFloat(width))
const width = getStyle(
el.value.firstElementChild as HTMLElement,
'width'
)
return Math.ceil(Number.parseFloat(width)) || 0
} else {
return 0
}