ionic 2 + angular 2 : auto scroll to bottom of list / page / chat

后端 未结 9 1484
误落风尘
误落风尘 2021-02-13 12:42

I\'m trying to code a page with two segments \"chat\" and \"content\". I want that one \"chat\" segment the page auto-scroll to the bottom with no effect. The chat is a &l

9条回答
  •  鱼传尺愫
    2021-02-13 13:16

    The Ionic has an option to do this and works pretty good: And this is the most appropriate way with angular 2+ and Ionic.

    import { Content } from ‘ionic-angular’;
    
    export class CommentsPage{
    @ViewChild(Content) content: Content;
    
        ionViewWillEnter(): void {
            this.scrollToBottom();
        }
    
        scrollToBottom() {
            setTimeout(() => {
                this.content.scrollToBottom();
            });
        }
    }
    

提交回复
热议问题