WebStorm中的绝对路径 [英] Absolute path In WebStorm
问题描述
我已经创建了一个简单的项目,我想链接3个文件: angular.min.js
, bootstrap.min.js
和 app.js
,如下图所示:
I've created a simple project to which I want to link 3 files: angular.min.js
, bootstrap.min.js
and app.js
like in the picture below:
看起来不错,没有警告.如果在index.html中按 Run (运行),则会出现以下错误:
This looks ok, no warnings. If I press Run while in index.html the following errors appear:
为了使错误消失,我必须将项目的名称( NewOne )放在我在 index.html
中引用的每个文件之前.例如: ... src =/NewOne/angular/angular.min.js ...
In order for the errors to disappear I have to place the name of the project (NewOne) before each file I reference in index.html
. Ex: ... src=/NewOne/angular/angular.min.js ...
这会生成警告,并禁用⌘+单击快捷方式以转到该文件.
This generates warnings and disables the ⌘+click shortcut to go the that file.
在WebStorm中指定绝对路径的正确方法是什么?
What is the correct way to specify absolute paths in WebStorm?
推荐答案
对于WebStorm版本2019.2,我执行了以下操作:
With WebStorm version 2019.2 i did the following:
1在Windows主机文件中编辑以下条目:
1 Edit in your windows hosts file the following entries:
127.0.0.1 localhost
127.0.0.1 MyProject
2在Webstorm中进入文件->设置->构建,执行,部署->部署",并添加一个新的部署位置,作为就地"类型.在"Web服务器URL:"字段中,必须输入" http://MyProject:63342/".单击应用",它应该可以工作.
2 Go in Webstorm to "File -> Settings -> Build, Execution, Deployment -> Deployment" and add a new deployment location as type "in place". In the field "Web server URL:" you have to input "http://MyProject:63342/". Click Apply and it should work.
现在以下网址应该可以使用:
Now the following URLs should be working:
http://localhost:63342/MyProject/index.html -> uses relatie paths
http://MyProject:63342/index.html -> uses absolute paths
请注意,端口63342是Webstorm的标准端口.也许您必须将其更改为您的特定端口.
Please be aware that the port 63342 is the standard port of Webstorm. Maybe you have to change it to your specific port.
这篇关于WebStorm中的绝对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!