{"action":"opened","issue":{"url":"https://api.github.com/repos/ziwei3749/blog/issues/18","repository_url":"https://api.github.com/repos/ziwei3749/blog","labels_url":"https://api.github.com/repos/ziwei3749/blog/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/ziwei3749/blog/issues/18/comments","events_url":"https://api.github.com/repos/ziwei3749/blog/issues/18/events","html_url":"https://github.com/ziwei3749/blog/issues/18","id":330107352,"node_id":"MDU6SXNzdWUzMzAxMDczNTI=","number":18,"title":"path.join和path.resolve的区别","user":{"login":"ziwei3749","id":21341502,"node_id":"MDQ6VXNlcjIxMzQxNTAy","avatar_url":"https://avatars1.githubusercontent.com/u/21341502?v=4","gravatar_id":"","url":"https://api.github.com/users/ziwei3749","html_url":"https://github.com/ziwei3749","followers_url":"https://api.github.com/users/ziwei3749/followers","following_url":"https://api.github.com/users/ziwei3749/following{/other_user}","gists_url":"https://api.github.com/users/ziwei3749/gists{/gist_id}","starred_url":"https://api.github.com/users/ziwei3749/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ziwei3749/subscriptions","organizations_url":"https://api.github.com/users/ziwei3749/orgs","repos_url":"https://api.github.com/users/ziwei3749/repos","events_url":"https://api.github.com/users/ziwei3749/events{/privacy}","received_events_url":"https://api.github.com/users/ziwei3749/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-07T03:52:04Z","updated_at":"2018-06-07T03:52:04Z","closed_at":null,"author_association":"OWNER","body":"# path.join和path.resolve的区别\r\n\r\n\r\n一句话解释的就是，join是拼接路径，resolve是解析路径\r\n\r\njoin直接拼接，比较呆板\r\n\r\n区别1： resolve一定会帮你解析出一个绝对路径，从右往左解析，当遇到/就直接返回，不再继续向左解析了。\r\n\r\n```\r\n path.join('/a','/b')   ==>  /a/b\r\n\r\n path.resolve('/a','/b') ==> /b     因为遇到/，判断已经是绝对路径了\r\n\r\n```\r\n\r\n\r\n\r\n区别2： resolve过程里,如果没遇到/会自动补全一个绝对路径\r\n\r\n\r\n```\r\npath.join('a','b1','..','b2')    ==> a/b2\r\n\r\n\r\npath.resolve('a','b1','..','b2')    ==>   /home/job/node/a/b2\r\n\r\n\r\n```\r\n"}}
{"actor":{"display_login":"ziwei3749"}}