优化:初步优化全局代码样式
This commit is contained in:
@@ -1,36 +1,39 @@
|
||||
/**
|
||||
* 格式化时间
|
||||
*
|
||||
* @param date 待格式化时间
|
||||
* @returns 格式化后的时间(YYYY/MM/dd AM hh:mm)
|
||||
*/
|
||||
export function formatDate(date) {
|
||||
const formatDate = new Date(date)
|
||||
return formatDate.toLocaleString('zh', {year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric'})
|
||||
const formatDate = new Date(date);
|
||||
return formatDate.toLocaleString('zh', {year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric'});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取URL路径中的指定参数
|
||||
* 获取 URL 路径中的指定参数
|
||||
*
|
||||
* @param paramName 参数名
|
||||
* @returns 参数值
|
||||
*/
|
||||
export function getQueryParam(paramName) {
|
||||
const reg = new RegExp("(^|&)"+ paramName +"=([^&]*)(&|$)")
|
||||
let value = decodeURIComponent(window.location.search.substr(1)).match(reg)
|
||||
const reg = new RegExp("(^|&)"+ paramName +"=([^&]*)(&|$)");
|
||||
let value = decodeURIComponent(window.location.search.substr(1)).match(reg);
|
||||
if (value != null) {
|
||||
return unescape(value[2])
|
||||
return unescape(value[2]);
|
||||
}
|
||||
return null
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到指定链接
|
||||
*
|
||||
* @param paramName 参数名
|
||||
* @param paramValue 参数值
|
||||
*/
|
||||
export function goToLink(url, paramName, paramValue) {
|
||||
if (paramName) {
|
||||
window.location.href = url + '?' + paramName + '=' + paramValue
|
||||
window.location.href = url + '?' + paramName + '=' + paramValue;
|
||||
} else {
|
||||
window.location.href = url
|
||||
window.location.href = url;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user