Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node 的一些知识点 #87

Open
gdutwyg opened this issue Nov 1, 2019 · 0 comments
Open

node 的一些知识点 #87

gdutwyg opened this issue Nov 1, 2019 · 0 comments
Labels

Comments

@gdutwyg
Copy link
Owner

gdutwyg commented Nov 1, 2019

path.join()和path.resolve()的区别

  • path.join 只是拼接path片段
  • path.resolve 拼接path片段后,返回一个绝对路径

举个例子:

// 区别1:
path.join('a','b') // a\b
path.resolve('a', 'b') // E:\code\node\express\a\b

// 区别2 
//  resolve识别拼接的如果首个字符是‘/’ 则把‘/’当成根目录
path.join('a', '/b') // a\b
path.resolve('a', '/b') // E:\b 

__dirname是当前目录的绝对路径

。。。未完待续

@gdutwyg gdutwyg added the node label Nov 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant