We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Node.js 提供了 url 模块,用于处理与解析 URL。
const { URL } = require("url"); const myURL = new URL("https://github.com/webfansplz#hello"); console.log(myURL); { href: 'https://github.com/webfansplz#hello', // 序列化的 URL origin: 'https://github.com', // 序列化的 URL 的 origin protocol: 'https:', // URL 的协议 username: '', // URL 的用户名 password: '', // URL 的密码 host: 'github.com', // URL 的主机 hostname: 'github.com', // URL 的主机名 port: '', // URL 的端口 pathname: '/webfansplz', // URL 的路径 search: '', // URL 的序列化查询参数 searchParams: URLSearchParams {}, // URL 查询参数的 URLSearchParams 对象 hash: '#hello' // URL 的片段 }
URL 对象属性 除了 origin 和 searchParams 是只读的,其他都是可写的.
const { URL } = require("url"); const myURL = new URL("https://github.com/webfansplz#hello"); console.log(myURL.href); // https://github.com/webfansplz#hello console.log(myURL.toString()); // https://github.com/webfansplz#hello console.log(myURL.toJSON()); // https://github.com/webfansplz#hello
上一节: [Node.js 入门系列] http 模块
下一节: [Node.js 入门系列] 压缩 zlib 模块
The text was updated successfully, but these errors were encountered:
No branches or pull requests
统一资源定位符 url 模块
Node.js 提供了 url 模块,用于处理与解析 URL。
1. URL 对象都有哪些属性 ?
URL 对象属性 除了 origin 和 searchParams 是只读的,其他都是可写的.
2. 序列化 URL
上一节: [Node.js 入门系列] http 模块
下一节: [Node.js 入门系列] 压缩 zlib 模块
The text was updated successfully, but these errors were encountered: