const querystring = require('querystring');
const url = require('url'); const querystring = require('querystring'); const urlString = 'https://www.example.com?name=John&age=25'; const parsedUrl = url.parse(urlString); const parsedQuery = querystring.parse(parsedUrl.query); console.log(parsedQuery); // 输出:{ name: 'John', age: '25' }
const query = { name: 'John', age: '25' }; const formattedQuery = querystring.stringify(query); console.log(formattedQuery); // 输出:name=John&age=25
本文为翻滚的胖子原创文章,转载无需和我联系,但请注明来自猿教程iskeys.com