當我在onSuccessCreateClass中添加到meteor.call回調中,並且出現此錯誤。不知道這裏有什麼問題嗎?發送調用結果的異常:TypeError:不是流星中的一個函數
Exception in delivering result of invoking 'createClass': TypeError: this.onSuccessCreateClass is not a function at http://localhost:3000/app/client/components/MyClasses.jsx?044c7b228d4b33fcea4b9f3c05da6d82e5e6c8b7:37:11 at null._callback (http://localhost:3000/packages/meteor.js?9730f4ff059088b3f7f14c0672d155218a1802d4:999:22) at _.extend._maybeInvokeCallback (http://localhost:3000/packages/ddp-client.js?250b63e6c919c5383a0511ee4efbf42bb70a650f:3500:12) at .extend.dataVisible (http://localhost:3000/packages/ddp-client.js?250b63e6c919c5383a0511ee4efbf42bb70a650f:3529:10) at http://localhost:3000/packages/ddp-client.js?250b63e6c919c5383a0511ee4efbf42bb70a650f:4365:7 at Array.forEach (native) at Function..each._.forEach (http://localhost:3000/packages/underscore.js?46eaedbdeb6e71c82af1b16f51c7da4127d6f285:149:11) at _.extend._runAfterUpdateCallbacks (http://localhost:3000/packages/ddp-client.js?250b63e6c919c5383a0511ee4efbf42bb70a650f:4364:7) at _.extend._livedata_data (http://localhost:3000/packages/ddp-client.js?250b63e6c919c5383a0511ee4efbf42bb70a650f:4354:10) at onMessage (http://localhost:3000/packages/ddp-client.js?250b63e6c919c5383a0511ee4efbf42bb70a650f:3361:12)
onSuccessCreateClass() {
console.log("Successfully created New Class")
$("#createClassModal").modal('hide')
$('#createClassModal').on('hidden.bs.modal', function() {
$(this).find('form').trigger('reset')
})
},
onPressSubmit(e) {
e.preventDefault()
const className = e.target.cname.value
console.log(this.props.courseId)
console.log(className)
if (Meteor.user().classes.length !== 0)
{
console.log("Got Class")
Meteor.call("createClass", this.props.courseId, className, function(error) {
if (error)
{
console.log(error.reason)
}
else
{
this.onSuccessCreateClass()
}
})
}
else
{
console.log("No Class")
Meteor.call("createNewClass", this.props.courseId, className, function(error) {
if (error)
{
console.log(error.reason)
}
else
{
this.onSuccessCreateClass()
}
})
}
},
其作品的感謝! – phongyewtong