Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs TypeError:无法执行';readAsBinaryString';在';文件读取器';:参数1的类型不是';水滴';_Reactjs - Fatal编程技术网

Reactjs TypeError:无法执行';readAsBinaryString';在';文件读取器';:参数1的类型不是';水滴';

Reactjs TypeError:无法执行';readAsBinaryString';在';文件读取器';:参数1的类型不是';水滴';,reactjs,Reactjs,我该怎么办? 我已经用npm下载了xlsx import React from "react" import XLSX from "xlsx" const Function = () => { const onClick = () => { document.getElementById('selectedFile').click(); } const excelExport = (event) =&g

我该怎么办? 我已经用npm下载了xlsx

import React from "react"
import XLSX from "xlsx"

const Function = () => {
    const onClick = () => {
        document.getElementById('selectedFile').click();
    }
    const excelExport = (event) =>{
        var input = event.target;
        var reader = new FileReader();
        reader.onload = function(){
            var fileData = reader.result;
            var wb = XLSX.read(fileData, {type : 'binary'});
            wb.SheetNames.forEach(function(sheetName){
               var rowObj =XLSX.utils.sheet_to_json(wb.Sheets[sheetName]);
               console.log(JSON.stringify(rowObj));
            })
        };
        reader.readAsBinaryString(input.files[0]);
    }
     return(
    <>
        <div className="function">
            <input type="file" id="selectedFile" onClick={excelExport}/>
            <input type="button" className="select-function" value="upload" onClick={onClick} />
            <input type="button" className="select-function" value="add"/>
            <input type="button" className="select-function" value="delete"/> 
        </div>
    </>
    )
    }
    

export default Function
TypeError: Failed to execute 'readAsBinaryString' on 'FileReader': parameter 1 is not of type 'Blob'.