简体   繁体   中英

HTML include js files

I realize this question has been asked many times, however I don't manage to make it working

I have an html file (main.html) that is including two js files (etherjs.js and web3-min.js). These files are in the same directory.

But when requesting the page through localhost node server, the files are not included in the page

What I am doing wrong?

Error of the console (it is saying error loading the eleent which source is:):

在此处输入图片说明

I think the problem is with your server.

If you use express:

To serve static files such as images, CSS files, and JavaScript files, use the express.static built-in middleware function in Express.

  1. Make a folder callled public in the root.
  2. Set it in your server: app.use(express.static('public'));
  3. Put in the files you need eg.: some.js .

Now you can call it with <script src="/some.js"></script>

More information

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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