javascript - 未捕获的 ReferenceError:显示未在 HTMLInputElement.onchange 中定义
问题描述
我正在尝试开发一个网络应用程序,其中输入获取书籍的文本文件并处理它以及流行词的数量但是发生了以下错误:
未捕获的 ReferenceError:显示未在 HTMLInputElement.onchange 中定义。通过 webpack 包装代码。请帮帮我!!
import './index.css';
import * as _ from 'lodash';
function show(input) {
const file = input.files[0];
const reader = new FileReader();
reader.readAsText(file, 'UTF-8');
reader.onload = () => {
const res = _.words(reader.result, /[а-яА-ЯёЁa-zA-Z]{4,}/gim);
const result = _.flow([
_.countBy,
_.toPairs,
_.partial(_.orderBy, _, 1, 'desc'),
_.partial(_.take, _, 10),
]);
const txt = result(res).map(([word, num]) => `<tr><td>${word}<td>${num}`).join('');
const out = document.getElementById('out');
out.insertAdjacentHTML('beforeend', txt);
};
}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>file</title>
<script defer src="bundle.js"></script></head>
<body>
<div>
<div id="drop-area">
Drag and drop file here
</div>
</div>
<div class="file-read">
<div class="file-input">
<label class="custom-file-upload">
<input type="file" id="input-file" onchange="show(this)" accept=".txt, .pdf, .epub, .fb2">
Upload a file
</label>
</div>
<a href="">Reset</a>
</div>
<div id="table-div">
<table id="out"></table>
</div>
</body>
</html>
解决方案
推荐阅读
- javascript - 尝试使用 react-apollo-hooks 在函数中调用 useQuery
- python - Rewriting Curl request in Python: Result Invalid Json
- angular - Formating Number / Currency in Angular 6 Directive
- javascript - 错误 - 不支持使用“requireCordovaModule”加载非 Cordova 模块“路径”
- angular - `ngFor` - 条件模板抛出错误为`Can't have multiple template bindings on one element`
- ffmpeg - 将覆盖图像添加到特定位置的视频ffmpeg
- flutter - 如何在 futureBuilder 中使用“toIso8601String”
- apache-kafka - 使用 Apache Kafka 作为 FTP 的替代方案
- sql - sql server 中的上限和综合服务器有什么区别
- jquery - 滚动时下拉菜单不会保持原位