反应文本ar并增长,但没有收缩,如何使其收缩?
我有这个反应组件,该组件成功地生长了文本方面。
.textarea {
resize: none;
overflow: hidden;
box-sizing: border-box;
}
export default function Textarea({
className,
onChange,
defaultValue,
...attrs
}) {
const handleInput = (e) => {
const h = e.target.scrollHeight
e.target.style.height = '0px'
e.target.style.height = `${h}px`
onChange?.(e)
}
return (
<textarea {...attrs} defaultValue={defaultValue} onInput={handleInput} className={styles.textarea} />
)
}
我该如何将其缩小到 nink ,它只会生长?
I have this React component, which successfully grows the textarea.
.textarea {
resize: none;
overflow: hidden;
box-sizing: border-box;
}
export default function Textarea({
className,
onChange,
defaultValue,
...attrs
}) {
const handleInput = (e) => {
const h = e.target.scrollHeight
e.target.style.height = '0px'
e.target.style.height = `${h}px`
onChange?.(e)
}
return (
<textarea {...attrs} defaultValue={defaultValue} onInput={handleInput} className={styles.textarea} />
)
}
How do I get it to shrink though, it only grows?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论