当前位置:网站首页>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
}
边栏推荐
- Hexadecimal representation of negative numbers
- ARouter源码解析(一)
- [autosar-rte] - 3-runnable and its task mapping mapping
- 译文推荐 | 调试 BookKeeper 协议 - 无界 Ledger
- MATLAB的符号运算
- LeetCode - 哈希表专题
- [附下载]推荐几款暴力破解和字典生成的工具
- FPGA development learning open source website summary
- 对话MySQL之父:代码一次性完成才是优秀程序员
- Activiti startup error: cannot create poolableconnectionfactory (could not create connection to database server
猜你喜欢

数据库核心体系

JDBC connection database

Introduction to shardingsphere's concept of sub database and sub table (2)

final关键字和枚举类型

Problems encountered in upgrading golang to version 1.18.4

Conditions and procedures of stock index futures account opening

2022 safety officer-b certificate examination simulated 100 questions and answers

Technology sharing | quick intercom integrated dispatching system

478-82(56、128、718、129)

oracle 创建用户且只有查询权限
随机推荐
C# 之 方法参数传递机制
376. Swing sequence [greedy, dynamic planning -----]
如何在多线程环境下使用 GBase C API ?
[swintransformer source code reading II] window attention and shifted window attention
21 day learning challenge - "AUTOSAR from introduction to mastery - practical part"
Promise实例如何解决地狱回调
数据泄漏、删除事件频发,企业应如何构建安全防线?
How does gbase 8A use preprocessing to quickly insert data?
ArrayList内部原理解析
Express builds a simple local background (1)
Salted fish esp32 instance - mqtt lit LED
376. 摆动序列【贪心、动态规划------】
[gossip] the development of programmers needs two abilities most
[summary of leetcode weekly competition] the 83rd fortnight competition of leetcode (7.23)
正负数值的正则表达式
2022 safety officer-c certificate special operation certificate examination question bank and answers
会议OA系统
mysql 最大建议行数2000w,靠谱吗?
Network engineering -- ranking of Chinese universities in Soft Science
C# 窗体应用使用对象绑定 DataGridView 数据绑定