UNPKG

@ssports_fe/ssutils

Version:
17 lines (14 loc) 348 B
/** * * @desc 获取url中hash值 * @param {String} name hash键值 * @return {String} */ const getHash = (name) => { let u = window.location.hash.slice(1); let re = new RegExp(name + '=([^&\\s+]+)'); let m = u.match(re); let v = m ? m[1] : ''; return (v === '' || isNaN(v)) ? v : v - 0; }; module.exports = getHash;