【发布时间】:2016-03-12 21:41:10
【问题描述】:
我只是想在一个自动执行的匿名函数中调用一个函数。每当我尝试调用一个函数时,我都会收到一条错误消息“Uncaught TypeError: createGesture() is not a function”
loadGesturesFromDatabase: function() {
var firebaseRef = new Firebase("https://test.firebaseio.com/");
this.loadFromFireBase(firebaseRef);
firebaseRef.on('value', function(dataSnapshot) {
dataSnapshot.val();
console.log(dataSnapshot.val()); // console showing the data //which fetched from firebase
//Only having issue when executing following line of code
this.loadJson(JSON.stringify(dataSnapshot.val()));
});
}
loadJson: function(json) {
}
【问题讨论】:
-
请显示错误的完整跟踪。回调中的 this 应该是指没有加载 loadJson 方法的 firebaseRef。
-
您在代码中的某处调用了一个未定义的函数
createGesture。搜索您的文件并发表评论。 -
this可能不是您所期望的那样。阅读this
标签: javascript firebase