当前位置:网站首页>Get the parameters of the browser address bar
Get the parameters of the browser address bar
2022-07-25 04:45:00 【Recall @y】
One 、 Business scenario :
Recently doing React When the project jumps to the details page , You need to intercept the parameters on the browser address bar to use , For everyone to meet the same problem as me later , Let me share with you
Two 、 Solution :
Encapsulate an interception function , Just pass in the name of the field you want to get
3、 ... and 、 Specific implementation steps :
Encapsulate functions that get parameter values
function getUrlParam(key){
var url = decodeURI(window.location.href);
var arr = url.split("?");
if(arr.length > 1){
var paramArr = arr[1].split("&");
for(var i = 0; i < paramArr.length; i++){
var param = paramArr[i];
if(param.split("=")[0] == key){
return param.split("=")[1];
}
}
}
}
Value
let id = getUrlParam("id")
console.log(id)
This is the end of today's sharing , Welcome friends to communicate together
边栏推荐
猜你喜欢

Apipost signs up with Chinatelecom! Work together to accelerate the digital transformation of enterprises

Style transfer -- CCPL: contrast coherence preserving loss for versatile style transfer

Paper:《Peeking Inside the Black Box: Visualizing Statistical Learning with Plots of Individual Condi

2019 telecast retest test questions

MCU experiment record

2、 Mysql database foundation

Token value replacement of burpsuite blasting

数据链路层协议 ——— 以太网协议

It we media shows off its wealth in a high profile, and is targeted by hacker organizations. It is bound to be imprisoned

Dark king | analysis of zego low illumination image enhancement technology
随机推荐
LVGL 8.2 Message box
If you don't know these 20 classic redis interview questions, don't go to the interview!
Only list the data of the specified field GetData ($table, '*', $where, $order)
GetData table table data join MySQL method
After watching the latest interview with big manufacturers, these six JVM interview questions were asked
Pyg builds GCN to realize link prediction
PyG搭建GCN实现链接预测
Paper:《Peeking Inside the Black Box: Visualizing Statistical Learning with Plots of Individual Condi
Data Lake (16): structured streaming writes iceberg in real time
Today is important
Construction of Seata multilingual system
Sudden! Britain accuses Huawei of major defects in its equipment (with report)
How to get the database creation time?
etcd学习
LVGL 8.2 Span
Burpsuite爆破之token值替换
在开发或调试IP直接方案时需要注意Host的值跟直接的IP要一致
如何取得数据库创建时间?
# 1. Excel的IF函数
Detailed explanation of security authentication of mongodb