book-detail.js:91 Uncaught (in promise) TypeError: _this2.data.comments.unshift is not a function
at book-detail.js:91
at
老师请问如何解决,一样的代码:
onPost(event) {
const comment = event.detail.text || event.detail.value
if(!comment){
return
}
if (comment.length > 12) {
wx.showToast({
title: '短评最多12个字',
icon: 'none'
})
return
}
bookModel.postComment(this.data.book.id, comment)
.then(res => {
wx.showToast({
title: '追加评论成功',
icon: 'none'
})
this.data.comments.unshift({
content: comment,
nums: 1
})
this.setData({
comments: this.data.comments,
posting: false
})
})