mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-05 04:37:47 +08:00
refactor(components): [form-label-wrap] use getStyle method (#13913)
This commit is contained in:
parent
ec639c4d14
commit
c6a6d9bc6e
@ -11,7 +11,7 @@ import {
|
|||||||
watch,
|
watch,
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
import { useResizeObserver } from '@vueuse/core'
|
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 { useNamespace } from '@element-plus/hooks'
|
||||||
import { formContextKey, formItemContextKey } from './constants'
|
import { formContextKey, formItemContextKey } from './constants'
|
||||||
|
|
||||||
@ -41,8 +41,11 @@ export default defineComponent({
|
|||||||
|
|
||||||
const getLabelWidth = () => {
|
const getLabelWidth = () => {
|
||||||
if (el.value?.firstElementChild) {
|
if (el.value?.firstElementChild) {
|
||||||
const width = window.getComputedStyle(el.value.firstElementChild).width
|
const width = getStyle(
|
||||||
return Math.ceil(Number.parseFloat(width))
|
el.value.firstElementChild as HTMLElement,
|
||||||
|
'width'
|
||||||
|
)
|
||||||
|
return Math.ceil(Number.parseFloat(width)) || 0
|
||||||
} else {
|
} else {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user