npm常用插件

一、query-string解析url参数

安装

pnpm i query-string -S

stringify

import qs from 'query-string';

const a = qs.stringify({ name: 'toms', like: ['run', 'play'], age: '' })
//name=toms&like=run&like=play&age=

parse

const b = qs.parse(a)
//{
  name: 'toms',
  like: [ 'run', 'play' ],
  age: ''
}

parseUrl

const c = qs.parseUrl('https://weibo.com?name=toms');
//{url:'https://weibo.com', query:{ name:'toms' }}

你可能感兴趣的:(npm,前端,node.js)