【发布时间】:2021-10-16 06:06:00
【问题描述】:
我是 Web 开发的初学者,我目前正在做一个项目,但无法加载 javascript 文件 insert.js。 html 文档 upload.html 位于 public 文件夹中,而 javascript 位于主文件夹中。 我使用以下路径来链接 javascript 文件,
<script src= "../insert.js"></script>
但是好像不行,于是我试着把upload.html移到主文件夹,也就是HR,我用了下面的代码,
<script src = "/insert.js"></script>
这也不起作用,所以我尝试将 insert.js 移动到公用文件夹,并使用与我上面提到的相同的路径,但是,我无法将变量导出到 app.js 这是位于 HR 主目录中。
The image I have attached shows location of the files
我不知道是什么原因造成的,我想我也应该提到这一点,但是在 node.js 中运行我的 javascript 文件时出现错误。所以我在 node_modules/whatwg-url/dist/encoding.js 中插入了以下代码:
const {TextDecoder, TextEncoder} = require("util");
我不知道这是否与我的问题有关,但我想我会提一下。
【问题讨论】:
标签: javascript html node.js express web-deployment