新人请教个问题,怎么理解node.js中URL的resolve方法
如题。查了下url的resolve方法。看到了个例子。
url.resolve('/one/two/three', 'four') // '/one/two/four'
url.resolve('http://example.com/', '/one') // 'http://example.com/one'
url.resolve('http://example.com/one', '/two') // 'http://example.com/two'
这三个结果无法理解。有人帮忙解释下吗
2 回复
文档么不看仔细:
The url.resolve() method resolves a target URL relative to a base URL in a manner similar to that of a Web browser resolving an anchor tag HREF.
和浏览器里的 a标签行为一致
拼接,容错