Console.log不是javascript中的函数错误

console.log is not a function - error in javascript

本文关键字:函数 错误 javascript log 不是 Console      更新时间:2023-09-26

我得到错误,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
 });

我已经将控制台重新定义为代码下面的函数!完成新手错误......希望我不会再犯这样的错误。