nodejs的url模块中的resolve()的用法总结

寻技术 JS脚本 / Node.Js 2023年07月09日 117
 var url = require('url');
 var a = url.resolve('/one/two/three', 'four') ,
 b = url.resolve('http://example.com/', '/one'),
 c = url.resolve('http://example.com/one', '/two');
 console.log(a +","+ b +","+ c);
 //输出结果:
 ///one/two/four
 //http://example.com/one
 //http://example.com/two

注意总结用法规律;

替换 域名后面第一个“/”后的内容;

关闭

用微信“扫一扫”