用打字稿写的,我有这个:
export class EventDiscussionPage {
messages: any = []
private _channel: any;
initChat() {
this._channel.on('messageAdded', function(message) {
this.messages.push(message);
}
}
}
添加消息后,我得到cannot read property 'push' of undefined
. 我想我遇到了范围问题 - 如何将消息添加到this.messages
?