1.1.1 • Published 4 years ago

enter-search-url v1.1.1

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

获取路由search参数

npm i search-url -D
import SearchUrl from 'search-url'
const UrlUtil = new SearchUrl()

// http://www.xxx.com/?type=1&code=2/#/
<!-- getPreValue -->
UrlUtil.SearchUrl('type') // 1
<!-- format -->
UrlUtil.format() // {type: 1, code: 2}
<!-- insetUrl -->
UrlUtil.insetUrl({login: true}) // http://www.xxx.com/?type=1&code=2&login=true/#/
<!-- go -->
UrlUtil.insetUrl({login: true}).go() // http://www.xxx.com/?type=1&code=2&login=true/#/

使用方法

方法类型描述
formatfunction获取链接参数
getPreValuefunction获取链接参数指定的key
insetUrlfunction向链接参数中插入指定的key
delParamsfunction删除链接参数中指定的key
gofunction一般结合insetUrl使用 跳转到插入的新路径