Skip to content

[html] 第137天 如何让textarea高度自适应呢? #1132

Open
@haizhilin2013

Description

@haizhilin2013
Collaborator

第137天 如何让textarea高度自适应呢?

Activity

LinStan

LinStan commented on Aug 31, 2019

@LinStan

使用div的contenteditable属性模拟textarea,通过设定min-height 然后用高度慢慢撑高区域。

dragon8github

dragon8github commented on Aug 31, 2019

@dragon8github

使用 div contenteditable 模拟的代价实在太大了。

推荐看看 ant-design 和 elementUI 的源码设计即可。

https://github.com/ElemeFE/element/blob/dev/packages/input/src/calcTextareaHeight.js#L73

https://github.com/ant-design/ant-design/blob/master/components/input/calculateNodeHeight.tsx#L88

whitesky1225

whitesky1225 commented on Sep 2, 2019

@whitesky1225

用UI框架用习惯了,能想到的就是看框架源码。。

tao7544

tao7544 commented on Oct 10, 2019

@tao7544

监听 input 事件,元素高度 = 元素可滚动高度

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @haizhilin2013@dragon8github@LinStan@tao7544@whitesky1225

        Issue actions

          [html] 第137天 如何让textarea高度自适应呢? · Issue #1132 · haizlin/fe-interview