url 模块
作用:url 模块用于处理与解析 URL。
使用前需引入:
const url = require('url');
1)url 属性说明
2)代码举例
const url = require('url');
let myUrl1 = url.parse('https://user:pass@sub.host.com:8080/p/a/t/h?name=xx#hash');
let myUrl2 = url.parse('https://user:pass@sub.host.com:8080/p/a/t/h?name=yy#hash', true);
console.log(myUrl1.query);
console.log(myUrl2.query);
querystring 模块
作用:querystring 模块是用于解析和格式化 URL 查询字符串的实用工具。
使用前需引入: