我有一个聊天API,正在连接到Vue.js项目。 当用户转到聊天室页面时,它将发送一个ajax请求,然后调用获取整个聊天记录的函数:
mounted() {
$.ajax({
url: `http://localhost:8000/api/rooms/${this.$route.params.id}/`,
data: {username: this.username},
type: 'PATCH',
success: (data) => {
const user = data.members.find((member) => JSON.parse(member).username === this.username)
if (user) {
// The user belongs/has joined the session
this.fetchChatSessionHistory(this.$route.params.id)
}
}
})
},
fetchChatSessionHistory (uri) {
$.get(`http://127.0.0.1:8000/api/rooms/${uri}/messages/`, (data) => {
this.messages = data.messages
})
},
但是失败了:
TypeError:_this.fetchChatSessionHistory不是函数
我知道可能在错误的位置定义了它,但是我不知道如何正确使用它。
答案 0 :(得分:3)
您应该将该函数放在SELECT Count(Audi.Id) AS CuentaDeId FROM Audi
WHERE (((Len." & filtro & ") Between #" & Format(Me!fechamin, "mm/dd/yyyy") & "# And #" & Format(Me!fechamax, "mm/dd/yyyy") & "#))
属性内,如下所示:
methods
答案 1 :(得分:0)
您可以执行以下操作:
mounted() {
var _this = this;
$.ajax({
url: `http://localhost:8000/api/rooms/${this.$route.params.id}/`,
data: {username: _this.username},
type: 'PATCH',
success: (data) => {
const user = data.members.find((member) => JSON.parse(member).username === _this.username)
if (user) {
// The user belongs/has joined the session
_this.fetchChatSessionHistory(_this.$route.params.id)
}
})
}