如何使用JS读取目录中的文件

时间:2019-05-06 09:20:51

标签: javascript html file fs client-side-scripting

我有一个index.html文件,它将调用main.js。在main.js中,我基于文件中的值创建一个图形,为此,我需要读取目录并从文件中读取值。

如何使用JS从目录读取文件

index.html

aaa<p>Radio and<br/> television.<br/></p><p>very<br> popular in the world today.</br></p><p>Millions of people watch TV. </p><p>That’s because a radio is very small 98.2%</p><p>and it‘s easy to carry. haha100%</p>bb

main.js

   <!DOCTYPE html>
   <html lang="en">
   <meta charset="UTF-8">

   <head>
   <!-- Plotly.js -->

   </head>

   <body>
    <div id="myDiv" style="width: 480px; height: 400px;">
    <!-- Plotly chart will be drawn inside this DIV -->
    </div>
    <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
  <script src="./main.js"></script>
</body>

</html>

0 个答案:

没有答案