javascript - 相对 JavaScript 路径不起作用

标签 javascript path

我将一个简单的 Angular 2 网站上传到我的 ftp。

奇怪的是,相对路径不起作用。

例如我在 myurl.de/subfolder/index.html

<script src="app/ext/es6-shim.min.js"></script>
<script src="app/ext/system-polyfills.js"></script>
...

浏览器在 myurl.de/app/ext/es6-shim.min.js 中搜索文件,而不是在 myurl.de/subfolder/ext/es6-shim.min 中搜索.js

最佳答案

我能想到的唯一会导致这种情况的就是 base element :

The base element allows authors to specify the document base URL for the purposes of resolving relative URLs, and the name of the default browsing context for the purposes of following hyperlinks. The element does not represent any content beyond this information.

例如,如果文档中有类似的内容

<base href="/">

这将更改文档的基本 URL,以便从那里计算相对 URL,而不是默认的基本 URL。

关于javascript - 相对 JavaScript 路径不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36181151/

相关文章:

javascript - 你能说这是 Javascript Closure 的一个正确的例子吗?我们需要考虑避免闭包的地方在哪里?

javascript - jquery 迭代 '.each' 中的数字

javascript - 没有提交表单的html5验证错误消息

Unix 变量最佳实践 : Should variable containing a path end in a slash

python - 为什么 "pip install"不起作用但 "python -m pip install"起作用?

ruby - 使用 wxRuby 的问题

javascript - 编写一个 JavaScript 来使用 for 循环求一系列的总和

javascript - Prettyphoto 中的照片不要显示两次

algorithm - 边数固定的最短路径

css - 如何使输出文件路径相对?