node.js中的url.parse方法使用说明
2023-06-13 09:15:32 时间
方法说明:
讲一个URL字符串转换成对象并返回。
语法:
url.parse(urlStr,[parseQueryString],[slashesDenoteHost])
接收参数:
urlStr url字符串
parseQueryString 为true时将使用查询模块分析查询字符串,默认为false
slashesDenoteHost
默认为false,//foo/bar形式的字符串将被解释成{pathname:‘//foo/bar"}
如果设置成true,//foo/bar形式的字符串将被解释成 {host:‘foo",pathname:‘/bar"}
例子:
vara=url.parse("http://example.com:8080/one?a=index&t=article&m=default");
console.log(a);
//输出结果:
{
protocol:"http",
auth:null,
host:"example.com:8080",
port:"8080",
hostname:"example.com",
hash:null,
search:"?a=index&t=article&m=default",
query:"a=index&t=article&m=default",
pathname:"/one",
path:"/one?a=index&t=article&m=default",
href:"http://example.com:8080/one?a=index&t=article&m=default"
}
相关文章
- Linux上的JS压缩工具(js压缩工具linux)
- Node.js连接MSSQL数据库的操作指南(node 链接mssql)
- 使用Node.js链接/操作MS SQL数据库(node mssql使用)
- js的一些常用方法小结
- JS跳转页面延迟2种方法
- 在服务端(Page.Write)调用自定义的JS方法详解
- JS获取节点的兄弟,父级,子级元素的方法
- Node.js和PHP根据ip获取地理位置的方法
- js改变鼠标的形状和样式的方法
- js实现键盘操作实现div的移动或改变的原理及代码
- node.js中的dns.getServers方法使用说明
- node.js中的events.EventEmitter.listenerCount方法使用说明
- node.js中的buffer.fill方法使用说明
- node.js中的http.request方法使用说明
- node.js中的fs.write方法使用说明
- node.js中的fs.symlink方法使用说明
- node.js中的fs.linkSync方法使用说明
- node.js中的fs.lstatSync方法使用说明
- node.js中的fs.lchmod方法使用说明
- node.js中的fs.lchown方法使用说明
- node.js中的fs.read方法使用说明
- node.js中的fs.openSync方法使用说明
- node.js中的fs.createReadStream方法使用说明
- js判断登录与否并确定跳转页面的方法