我在.then promise
中调用此函数this.retrieveMatches();
此功能如下所示
retrieveMatches: function(){
var tableResult = makeHTMLMatchesTable(fetchMatches());
var matches = document.getElementById('matches')
matches.parentNode.insertBefore(tableResult, matches);
},
这个功能正好在它上面:
makeHTMLMatchesTable: function(array){
//does stuff
}
那么为什么控制台这样说:
Uncaught (in promise) ReferenceError: makeHTMLMatchesTable is not defined
什么时候明确定义了?
答案 0 :(得分:0)
更改此代码
retrieveMatches: function(){
var tableResult = makeHTMLMatchesTable(fetchMatches());
var matches = document.getElementById('matches')
matches.parentNode.insertBefore(tableResult, matches);
},
到
retrieveMatches: function(){
var tableResult = this.makeHTMLMatchesTable(fetchMatches());
var matches = document.getElementById('matches')
matches.parentNode.insertBefore(tableResult, matches);
}.bind(this),