Package Exports
- @jswork/next-param
- @jswork/next-param/dist/index.esm.js
- @jswork/next-param/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@jswork/next-param) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
next-param
Parse and stringify URL query strings for next.
installation
npm install -S @jswork/next-param
apis
name | type | description |
---|---|---|
hash | object | 传入的参数列表 |
url | string | URL |
options | object | 其它选项 |
options
name | type | description |
---|---|---|
separator | string | 当参数值为 array 的时候, join 的连接字符 |
encode | function | encodeURI 或者 encodeURIComponent ,或者自定义 |
isEmpty | function | 过渡掉不需要的 value ,可以用这个函数;默认过滤掉 null/undefined |
transform | function | 对每一组 key/value 进行处理,最终返回需要用 & 拼接的字符串 |
encode
- uri: 用
encodeURIComponent
对 value 进行 1次encode
处理 - uri2: 用
encodeURIComponent
对 value 进行 2次encode
处理 - base64: 对 value 用
js-base64
进行encode
usage
import '@jswork/next-param';
nx.param({ var1: 123, var2: 'str', ids: [1,2,3] });
// var1=123&var2=str&ids=1%2C2%2C3
license
Code released under the MIT license.