当前位置:网站首页>Common tool functions are constantly updated
Common tool functions are constantly updated
2022-07-28 09:38:00 【Weave_ network】
Refresh the page only once
/** * @paramstr Refresh once */
export const refreshOnce = (hrefUrl) => {
let url = hrefUrl // Assign the address of the current page to the variable url
const times = url.split('?') // Tangential variable url The separator is “?”
if (times[1] != 1) {
// If ? The value after is not equal to 1 Indicates that there is no refresh
url += '?1' // Put variables url Add the value of ?1
self.location.replace(url) // Refresh the page
}
}
Page using
import {
refreshOnce } from '@/utils'
refreshOnce(location.href)
obtain url Parameter object
/** * @paramstr obtain url Parameter object */
export const parseQueryString = (url: string) => {
// Write code to achieve
// 1. lookup ? The subscript
const index = url.indexOf('?')
// 2. Intercept ? String after
const str = url.slice(index + 1)
// 3. according to & Convert string to array
const arr = str.split('&')
// 4. Declare objects to store information
const obj = {
}
for (let i = 0; i < arr.length; i++) {
// arr[0] action=home
const arr2 = arr[i].split('=')
// arr2 The first member of does attribute , The second member does value
obj[arr2[0]] = arr2[1]
}
return obj
}
Page using
import {
parseQueryString } from '@/utils'
const hrefUrl = window.location.href
const {
mall } = parseQueryString(hrefUrl)
if (mall == 1) {
// Jump to the use of another project Development , test , formal
if (process.env.VITE_USER_NODE_ENV == 'development') {
window.location.href = `http://XXX.XXX.XXX.XXX:8081/#/admin/shop?token=${
res.result.token}`
} else {
hrefUrl.indexOf('test') != -1
? (window.location.href = ` Test prefix /#/admin/shop?token=${
res.result.token}`)
: (window.location.href = ` Official prefix /#/admin/shop?token=${
res.result.token}`)
}
return
}
边栏推荐
- Activiti startup error: cannot create poolableconnectionfactory (could not create connection to database server
- 可以伸缩的搜索栏,模仿华为应用市场
- Retrofit源码解析
- Conference OA system
- 2022 examination question bank and simulation examination of crane driver (limited to bridge crane)
- LeetCode - 哈希表专题
- HashSet内部原理解析
- Personal blog applet
- sql server 的关键字在哪张系统表?
- 7 C control statements: branches and jumps
猜你喜欢

DN-DETR 论文精度,并解析其模型结构 & 2022年CVPR论文

Oracle-11gR2默认的系统JOB

【打包部署】

IJCAI 2022 | 图结构学习最新综述:研究进展与未来展望

【vscode】vscode使用

译文推荐 | 调试 BookKeeper 协议 - 无界 Ledger

Activiti启报错: Cannot create PoolableConnectionFactory (Could not create connection to database server

ShardingSphere简介(一)

LeetCode - 哈希表专题

21 day learning challenge - "AUTOSAR from introduction to mastery - practical part"
随机推荐
《PyTorch深度学习实践》第九课多分类问题(手写数字MNIST)
Technology sharing | quick intercom integrated dispatching system
[multithreading] non atomic agreement of long and double
7 C control statements: branches and jumps
[C language] detailed explanation sequence table (seqlist)
Dn-detr paper accuracy, and analyze its model structure & 2022 CVPR paper
数据库核心体系
c# 有符号和无符号字节变量
express搭建一个简易的本地后台(一)
【一花一世界-郑一教授-繁简之道】可解释神经网络
[summary of leetcode weekly competition] the 83rd fortnight competition of leetcode (7.23)
5 operators, expressions, and statements
2022 high voltage electrician examination simulated 100 questions and simulated examination
[JVM] JVM refers to floating point number
matlab基本操作
[multithreading] the underlying principle of println method
2022 safety officer-b certificate examination simulated 100 questions and answers
Window源码解析(四):Window的删除机制
技术分享| 快对讲综合调度系统
【广西大学】考研初试复试资料分享