您的位置:首页 > 其它

.和..在路径中的区别

2015-10-20 11:45 141 查看
最近在做一个nwjs + nodejs + polymer的项目。项目快做好了,需要把代码打包成可以直接运行的文件。

本来的文件结构是:

app

--bower_components

--node_modules

--src

|--client

|--index.html

|--elements.html

index.html、elements.html里面对node和polymer的依赖的引用全写成了“../../node_modules/XXX”和“../../bower_components/XXX”的形式。

nwjs的打包文档要求把**.html全部挪到app目录下。挪完之后把依赖路径里的“../../“去掉,成为”node_modules/XXX“和”bower_components/XXX“。这时候再运行app,发现nwjs开始报错找不到node_modules里面某几个的包,polymer组件的加载也无法完成。

网上各种搜,找不到相关的资料。最后试着把在路径开头加上"../"或者”./“,成为”../node_modules/XXX“和”./node_modules/XXX“,发现问题居然解决了。卡了那么久,解决方案竟然如此简单,真是不知道说什么好。

.是当前目录,..是上一级目录。
http://stackoverflow.com/a/6008906/2177408
A
./
in
front of the URL is equivalent to the current path. So
./delete-misc/test-ajax-code.php
and
delete-misc/text-ajax-code.php
are
both relative paths. In the answer you posted, you asked to remove the dot only, so the path of
/delete-misc/test-ajax-code.php
would
translate as an absolute path instead of a relative path.

Edit: one more thing -
.
is
the current directory and
..
is
the parent directory. As phihag comments, these really should be avoided and protected against in code. Directory traversal can be used for evil.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: