<!doctype html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <title>上传文件</title> </head> <body> <input type="file" id="testJsonFile" onchange="openFile(event)" > <script type="text/javascript"> //获取到选中的文件 var openFile = function (event) { var input = event.target; var reader = new FileReader(); reader.onload = function () { if (reader.result) { //显示文件内容 console.log(reader.result); } }; reader.readAsText(input.files[0]); }; </script> </body> </html>视频讲解地址 https://www.bilibili.com/video/BV1LL4y167re
JavaScript读取本地Json或txt文本文件
60.179.170.*2021-11-12 22:04:20
不错,感谢分享223.64.29.*2021-10-25 17:03:32
谢谢
114.249.26.*2021-11-29 15:41:29
不能识别文字吗?字母可以,文字乱码