[英]console.log is not a function - error in javascript
我收到錯誤消息, console.log
不是函數,但這在過去不是問題。 錯誤發生在第一個和第二個console.log
,並且沒有過去。
我有分號,所以我不確定到底是什么問題?
document.getElementById("fileToRead").addEventListener("change",function(event) {
var input = document.getElementById("fileToRead");
//Variable for if statement to see if there is a header in the file.
var headerType = false;
console.log(input);
input = event.target.files[0];
console.log('test');
for(var i = 0; i < input.files.length; i++){
var files = input.files[i];
Papa.parse(files, {
header:headerType,
dynamictyping:true,
complete:function(results){
console.log(results);
var input = results.data;
if(headerType === false){
input.forEach(function(input){
jsonData.theData = theData;
var singleEntry = {
"symbol" : input[0],
"date" : input[1],
"open" : input[2],
"high" : input[3],
"low" : input[4],
"close" : input[5],
"volume" : input[6]
};
jsonData.theData.push(singleEntry);
return jsonData;
}); // End forEach loop
} else {
} // End if statement for headerType
document.getElementById("editor").innerHTML = JSON.stringify(jsonData.theData);
} // End Callback Complete
}); // End PapaParse
} // End for loop
});
我什至注釋掉了代碼,所以這是最終結果,它仍然說console.log
不是一個函數!
// This is for the views/admin.ejs file only
//This file describes how the Admin page works, hiding divs and working with the data
// importing
var jsonData = {};
var theData = [];
document.getElementById("fileToRead").addEventListener("change",function(event) {
// var input = document.getElementById("fileToRead")
// //Variable for if statement to see if there is a header in the file.
// var headerType = false;
// input = event.target.files[0];
console.log('test');
// for(var i = 0; i < input.files.length; i++){
// var files = input.files[i];
// Papa.parse(files, {
// header:headerType,
// dynamictyping:true,
// complete:function(results){
// console.log(results);
// var input = results.data;
// if(headerType === false){
// input.forEach(function(input){
// jsonData.theData = theData;
// var singleEntry = {
// "symbol" : input[0],
// "date" : input[1],
// "open" : input[2],
// "high" : input[3],
// "low" : input[4],
// "close" : input[5],
// "volume" : input[6]
// };
// jsonData.theData.push(singleEntry);
// return jsonData;
// }); // End forEach loop
// } else {
// } // End if statement for headerType
// document.getElementById("editor").innerHTML = JSON.stringify(jsonData.theData);
// } // End Callback Complete
// }); // End PapaParse
// } // End for loop
});
我已將控制台重新定義為代碼下方的函數! 完全新手錯誤......希望我不會再犯這個錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.