调用的setData为什么不更新?
为什么我设置了setData,数据不更新?我使用调试工具看到AppData里也没更新?setData到底如何使用? send方法中的this也正常的啊 [图片] send(e) {
let msg = {};
this.data.messageList.push(msg, { role: 'placeholder' });
updateMsgMap(this.data.messageList);
this.setData({
messageList: this.data.messageList,
title: '正在输入...'
}, () => this.scrollToBottom());
sending = true;
request({
method: 'POST',
path: `xxx`,
data: payload,
}).then(res => {
this.data.messageList.pop();
const { u1, u2 } = res;
u1.suggest = u2.content.suggestion;
let last = this.data.messageList.pop();
last = {...last, ...u1};
this.data.messageList.push(last);
if (u2.type === 'audio') {
u2.audio_play = false;
};
this.data.messageList.push(u2);
if (u2.content.isFinish) {
this.data.messageList.push({ role: "summary" });
}
updateMsgMap(this.data.messageList);
this.setData({
messageList: this.data.messageList,
title: 'title'
}, () => this.scrollToBottom())
sending = false;
}).catch(err => {
sending = false;
})
},