【发布时间】:2021-09-17 15:06:54
【问题描述】:
所以我正在构建一个聊天应用程序,每次您发送消息时,您都会自动滚动到底部,我使用此代码来执行此操作
.html
<div class="chatContent" #scrollMe [scrollTop]="scrollMe.scrollHeight">
.ts
@ViewChild('scrollMe') scrollMe;
this.shouldScroll = this.scrollMe.scrollTop + this.scrollMe.clientHeight ===this.scrollMe.scrollHeight;
if (!this.shouldScroll) {
this.scrollToBottom();
}
scrollToBottom() {
this.scrollMe.scrollTop = this.scrollMe.scrollHeight;
}
出现这个错误
我已经看到这篇帖子Binding scrollTop directly in template gives error,但刷新页面后仍然出现该错误
【问题讨论】:
标签: angular typescript