diff --git a/src/utils/util.js b/src/utils/util.js index 7ec346d..7b436b1 100644 --- a/src/utils/util.js +++ b/src/utils/util.js @@ -7,8 +7,14 @@ export function getNowTime () { } export function getUrlParam (name) { - const search = window.location.search; - if (search !== '') { + let {search} = window.location; + const {hash} = window.location; + // # 在 ? 之前,即 http://localhost/#file?key=value,会导致 search 为空。 + if (search === '' && hash !== '') { + // 为 search 补上前缀'?',以便后面的逻辑处理不变。 + search = `?${hash.split('?')[1]}`; + } + if (search !== '' && search !== undefined) { const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i'); const r = search.substr(1).match(reg); if (r != null) { @@ -103,4 +109,4 @@ export const isMacOs = hasUaName('macintosh'); export const isOldEdge = hasUaName('edge') && !hasUaName('chrome'); -export const isIE = isOldEdge || hasUaName('trident') || hasUaName('msie'); \ No newline at end of file +export const isIE = isOldEdge || hasUaName('trident') || hasUaName('msie');