From 47316adf0c56b05be510bb7e9b2193018cf14b15 Mon Sep 17 00:00:00 2001 From: qiang Date: Wed, 11 May 2022 19:59:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20textarea=20?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=9B=BA=E5=AE=9A=20box-sizing=20=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E9=83=A8=E5=88=86=E6=83=85=E5=86=B5=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98=20question/121893?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/uni-components/src/vue/textarea/index.tsx | 7 +++++-- packages/uni-components/style/textarea.css | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/uni-components/src/vue/textarea/index.tsx b/packages/uni-components/src/vue/textarea/index.tsx index 2dc301fd6..1f21e9de7 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 ( -
+