get-url-params

1.0.1 • Public • Published

get-url-params

npm npm David David GitHub stars

提示

如果 url 参数存在多个 key 相同而 value 不同时,会强制使用第一个参数

安装


yarn:

yarn add get-url-params

npm:

npm i --save get-url-params

演示


import getUrlParams from 'get-url-params';
 
console.log(getUrlParams());          // 获取当前页面 url 参数 location.href = 'https://h.hnzycfc.com/alipay/?id=123'
console.log(getUrlParams('https://h.hnzycfc.com/promotion/?channel=zyxf_jg_pyq_5&id=1273733713'));      // 获取 url 字符串参数
 

输出

{ id: 123 }

{ channel: 'zyxf_jg_pyq_5', id: '1273733713' }

License

Licensed under the MIT License, Copyright © 2018-present hnzycfc.com, https://www.hnzycfc.com/

See LICENSE for more information.

/get-url-params/

    Package Sidebar

    Install

    npm i get-url-params

    Weekly Downloads

    2

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    10.3 kB

    Total Files

    7

    Last publish

    Collaborators

    • thestral
    • hnzycfc-npm
    • danielzd
    • dingjinhu