我将一个简单的 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/