mirror of
https://gitee.com/hhyykk/ipms-sjy-ui.git
synced 2025-07-15 19:35:07 +08:00
营销:商城装修增加控件【APP 链接选择】
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
import { toNumber } from 'lodash-es'
|
||||
|
||||
/**
|
||||
*
|
||||
* @param component 需要注册的组件
|
||||
@ -263,3 +265,23 @@ export const calculateRelativeRate = (value?: number, reference?: number) => {
|
||||
|
||||
return ((100 * ((value || 0) - reference)) / reference).toFixed(0)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取链接的参数值
|
||||
* @param key 参数键名
|
||||
* @param urlStr 链接地址,默认为当前浏览器的地址
|
||||
*/
|
||||
export const getUrlValue = (key: string, urlStr: string = location.href): string => {
|
||||
if (!urlStr || !key) return ''
|
||||
const url = new URL(decodeURIComponent(urlStr))
|
||||
return url.searchParams.get(key) ?? ''
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取链接的参数值(值类型)
|
||||
* @param key 参数键名
|
||||
* @param urlStr 链接地址,默认为当前浏览器的地址
|
||||
*/
|
||||
export const getUrlNumberValue = (key: string, urlStr: string = location.href): number => {
|
||||
return toNumber(getUrlValue(key, urlStr))
|
||||
}
|
||||
|
Reference in New Issue
Block a user