diff --git a/packages/uni-components/src/vue/textarea/index.tsx b/packages/uni-components/src/vue/textarea/index.tsx index 2dc301fd6a4590544718e922227e5b9a7459536b..1f21e9de784ea670807a151808457552f234000c 100644 --- a/packages/uni-components/src/vue/textarea/index.tsx +++ b/packages/uni-components/src/vue/textarea/index.tsx @@ -46,6 +46,7 @@ export default /*#__PURE__*/ defineBuiltInComponent({ emits: ['confirm', 'linechange', ...fieldEmit], setup(props, { emit }) { const rootRef: Ref = ref(null) + const wrapperRef: Ref = ref(null) const { fieldRef, state, scopedAttrsState, fixDisabledColor, trigger } = useField(props, rootRef, emit) const valueCompute = computed(() => state.value.split(LINEFEED)) @@ -57,6 +58,7 @@ export default /*#__PURE__*/ defineBuiltInComponent({ (height) => { const el = rootRef.value as HTMLElement const lineEl = lineRef.value as HTMLElement + const wrapper = wrapperRef.value as HTMLElement let lineHeight = parseFloat(getComputedStyle(el).lineHeight) if (isNaN(lineHeight)) { lineHeight = lineEl.offsetHeight @@ -68,7 +70,8 @@ export default /*#__PURE__*/ defineBuiltInComponent({ lineCount, }) if (props.autoHeight) { - el.style.height = height + 'px' + el.style.height = 'auto' + wrapper.style.height = height + 'px' } } ) @@ -147,7 +150,7 @@ export default /*#__PURE__*/ defineBuiltInComponent({ ) return ( -
+