在nodejs传递地址时,何时放置'/'在目录之间以及何时放置' \\' 。为什么我们要在写作地址之前放置点(。)
在nodejs中传递地址时,何时在目录之间和何时放置'\'。为什么我们要在写作地址之前放置点(。)
While passing address in nodejs, when to place '/' between directories and when to place '\' . And why do we place dot(.) before writing addresses
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
路径软件包提供功能,因此您不必担心需要哪种目录分离器使用。
dot代表当前目录IE
path package provides functionality so that you don't need to worry about what directory separator you need to use.
And dot represents current directory i.e.
在UNIX/Linux环境中,您将前向斜杠作为文件夹Seperator。
例如,
在Windows系统中,您将BackSlashes用作文件夹Seperator,因为BackSlash也是字符串中的逃生字符,因此您应该逃脱后挡板。
例如C:\ users \ user \ image.jpg
您使用的。对于相对路径。
例如,如果您的脚本在/home/home/user/中运行,并且您想访问image.jpg,则可以通过./image.jpg进行。
有关更多信息: https://nodejs.org/api/path.html
In a Unix/Linux environments you place a forward slash as a folder seperator.
e.g. /home/user/image.jpg
In a Windows system you use backslashes as folder seperators, since a backslash is also an escape character in a string you should escape the backslash.
e.g. C:\users\user\image.jpg
You use a . for relative paths.
e.g. if your script runs in /home/user/ and you want to access image.jpg you can do so by ./image.jpg
for more info: https://nodejs.org/api/path.html