UNPKG

superyoung-js

Version:

工具集

24 lines (23 loc) 662 B
/* * @Description: 处理URL等相关操作 * @Author: SuperYoung * @Date: 2019-12-04 22:41:42 * @LastEditors: SuperYoung * @LastEditTime: 2019-12-04 22:48:20 */ /** * @description: 获取get请求方式附带的参数 * @author: SuperYoung * @Date: 2019-12-04 22:42:18 * @lastEditors: SuperYoung * @param {String} name * @return: */ export function getQueryParam(name) { const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i') const url = window.location.href const search = url.substring(url.lastIndexOf('?') + 1) const r = search.match(reg) if (r != null) return unescape(r[2]) return null }