Nodejs模块:querystring

mac2022-06-30  30

/** * @description querystring模块 */ const querystring = require('querystring'); const url = 'https://www.trip.com/things-to-do/list?searchtype=1&searchkey=2&cityid=58&keyword=disney'; const queryUrl = url.split('?')[1]; console.log(querystring.parse(queryUrl)) //{ searchtype: '1', // searchkey: '2', // cityid: '58', // keyword: 'disney' } const params = { searchtype: '1', searchkey: '2', cityid: '58', keyword: 'disney' }; console.log(querystring.stringify(params)) // searchtype=1&searchkey=2&cityid=58&keyword=disney

  

转载于:https://www.cnblogs.com/yanchenyu/p/11300435.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)