【问题标题】:ion-textarea autoGrow scroll to top on inpution-textarea autoGrow 在输入时滚动到顶部
【发布时间】:2021-08-10 06:45:38
【问题描述】:

在我的离子5的应用程序当ion-textareaautoGrow="true"变长的高度,它总是滚动到上输入顶部,当用户的输入超出屏幕的高度。 here 报告了这个确切的问题,据说该修复程序已合并 here

我的 Ionic 版本是 6.16.1,我正面临这个问题。问题可以查here

【问题讨论】:

    标签: ionic-framework textarea ionic5 autogrow


    【解决方案1】:

    通过检查您共享的链接,这个答案似乎适用于您的 stackblitz:https://github.com/ionic-team/ionic-framework/pull/19776#issuecomment-549735550

    在您的 html 中:

    <ion-textarea auto-grow="true" (ionInput)="onTextInput($event)"> </ion-textarea>
    

    在您的 .ts 文件中:

    onTextInput(event) { event.target.getInputElement().then((textArea: HTMLTextAreaElement) => { console.log(textArea.textLength + " : " + textArea.value); textArea.scroll({top: textArea.scrollHeight}); }); }
    

    【讨论】:

    • 是的,这是一种解决方法,我已经对其进行了测试。我正在 Ionic 5 中寻找解决此问题的方法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-30
    • 1970-01-01
    相关资源
    最近更新 更多