![](/img/trans.png)
[英]is it possible? how to access node.js file from different node.js file in different directory?
[英]Access a JS file from a different directory
我有一个具有以下结构的项目:
project | -
public | -
-index.html
src | -
-index.js
导入文件的代码是:
<script src="../src/index.js"></script>
它不起作用。 任何想法为什么?
假设public
是唯一带有 URL 的目录(即您使用http://example.com/index.html
访问 index.html ):您不能。
浏览器只能通过请求它的 URL 来访问文件,如果你没有把它public
那么它就没有 URL。
任何一个:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.