Skip to content

Commit 9bfdbe1

Browse files
committed
feat(ChatList): add scrollToBottom method demo
1 parent 6e40d6b commit 9bfdbe1

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

packages/pro-components/chat/chat-list/_example/base/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ Component({
6767
},
6868

6969
methods: {
70+
// 调用chatList的滚动到底部方法
71+
scrollToBottom() {
72+
const chatListComponent = this.selectComponent('#chatList');
73+
if (chatListComponent && typeof chatListComponent.scrollToBottom === 'function') {
74+
chatListComponent.scrollToBottom();
75+
}
76+
},
7077
onScroll(e) {
7178
console.log('监听滚动', e);
7279
},

packages/pro-components/chat/chat-list/_example/base/index.wxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<view class="chat-box" style="height: {{contentHeight}};">
2-
<t-chat bindscroll="onScroll">
2+
<t-chat id="chatList" bindscroll="onScroll">
33
<block wx:for="{{chatList}}" wx:key="index">
44
<t-chat-message
55
avatar="{{item.avatar || ''}}"

0 commit comments

Comments
 (0)