正式url获取值

This commit is contained in:
zhangguoping 2024-09-02 10:09:47 +08:00
parent 56f9356a48
commit fb332bf0a5
1 changed files with 4 additions and 23 deletions

View File

@ -50,29 +50,8 @@ const srcList = reactive<SrcListType>({
}) })
const getUrlPathName = () => { const getUrlPathName = () => {
const url = window.location.href const url = window.location.pathname
if (url.indexOf('#/') !== -1) { try {
let strR = ''
const str =
url.indexOf('#/') !== -1 ? url.split('#/')[1] : url.split('/')[url.split('/').length - 1]
if (str.indexOf('/') === -1) {
strR = str || ''
} else {
strR = str.split('/')[0]
}
if (strR.indexOf('-') === -1) {
code = 'activity'
} else {
code = strR.split('-')[0]
strR = strR.split('-')[1]
}
return strR
} else if (url.indexOf('?') !== -1) {
let strR = ''
strR = url.split('=')[1]
code = strR.split('-')[0]
return strR.split('-')[1]
} else {
const str = url.split('/') const str = url.split('/')
const strP = str[str.length - 1] const strP = str[str.length - 1]
let strR = '' let strR = ''
@ -84,6 +63,8 @@ const getUrlPathName = () => {
strR = strP.split('-')[1] strR = strP.split('-')[1]
} }
return strR return strR
} catch {
return ''
} }
} }