繁体   English   中英

console.log 不是函数 - javascript 中的错误

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM