.和..在路径中的区别

最近在做一个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

./ in front of the URL is equivalent to the current path. So ./delete-misc/test-ajax-code.phpand 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.



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值