当前位置:网站首页>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
}
边栏推荐
- Talk to the father of MySQL: code completion at one time is a good programmer
- C# 窗体应用使用对象绑定 DataGridView 数据绑定
- 使用Xposed对软件进行破解
- 2.9.5 ext JS object type processing and convenient methods
- 51 single chip microcomputer storage: EEPROM (I2C)
- [Guangxi University] information sharing of postgraduate entrance examination and re examination
- Express builds a simple local background (1)
- Activiti startup error: cannot create poolableconnectionfactory (could not create connection to database server
- Problems encountered in upgrading golang to version 1.18.4
- 5 operators, expressions, and statements
猜你喜欢
![[swintransformer source code reading II] window attention and shifted window attention](/img/fb/5273d87fed66c75a92aec8e94980a3.png)
[swintransformer source code reading II] window attention and shifted window attention
![[package deployment]](/img/6f/93a35436947311bc2305adcb0df1a6.png)
[package deployment]
![Magic brace- [group theory] [Burnside lemma] [matrix fast power]](/img/cf/606d1bc7cd877771afbdd7640b718c.png)
Magic brace- [group theory] [Burnside lemma] [matrix fast power]

mq的学习

对话MySQL之父:代码一次性完成才是优秀程序员

Promise learning notes

Detailed introduction of v-bind instruction

QT basic hand training applet - simple calculator design (with source code, analysis)

【日志】日志干什么的?日志工厂是什么?log4j 的配置和使用? log4j.properties 文件配置、log4j jar包坐标

Network engineering -- ranking of Chinese universities in Soft Science
随机推荐
Magic brace- [group theory] [Burnside lemma] [matrix fast power]
go语言切片Slice和数组Array对比panic runtime error index out of range问题解决
【高数】高数平面立体几何
Informatics Olympiad all in one 1617: circle game | 1875: [13noip improvement group] circle game | Luogu p1965 [noip2013 improvement group] circle game
QT basic hand training applet - simple calculator design (with source code, analysis)
Personal blog applet
ARouter源码解析(一)
【多线程】long和double的非原子性协定
19c SYSAUX表空间SQLOBJ$PLAN表过大,如何清理
【广西大学】考研初试复试资料分享
数据泄漏、删除事件频发,企业应如何构建安全防线?
2022 supplementary questions for the first session of Niuke multi school
golang升级到1.18.4版本 遇到的问题
【AUTOSAR-RTE】-3-Runnable及其Task Mapping映射
Talk to the father of MySQL: code completion at one time is a good programmer
C# 窗体应用使用对象绑定 DataGridView 数据绑定
Openshift 4 - use verticalpodautoscaler to optimize application resource request and limit
Common prototype methods of canvas and the application of drawing pictures
GBase 8a如何使用使用预处理快速插入数据?
JDBC连接数据库