Skip to content

Commit 413fca3

Browse files
committed
add-post
1 parent cb0dbb9 commit 413fca3

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

_posts/2025-05-20-下载github文件.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ catalog: true
99
stickie: false
1010
tags:
1111
- git
12+
- 命令行
13+
- github
1214
---
1315

1416
### 下载github文件
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
layout: post
3+
title: uniapp隐藏参数
4+
subtitle: H5获取参数后移除浏览器的显示
5+
date: 2025-06-16 08:06:12 GMT+0800
6+
author: 920
7+
header-img:
8+
catalog: true
9+
stickie: false
10+
tags:
11+
- uniapp
12+
---
13+
14+
15+
####
16+
17+
```js
18+
// 在页面的onLoad生命周期中调用此函数
19+
onLoad(options) {
20+
// 处理接收到的参数
21+
this.handleTab(options.tab)
22+
// 移除URL中的参数
23+
this.removeUrlParam('tab')
24+
},
25+
26+
methods: {
27+
handleTab(tab) {
28+
// 处理tab参数的逻辑
29+
console.log('当前tab:', tab)
30+
},
31+
32+
removeUrlParam(paramKey) {
33+
const currentUrl = window.location.href
34+
const urlObj = new URL(currentUrl)
35+
36+
// 如果URL中存在该参数,则移除它
37+
if (urlObj.searchParams.has(paramKey)) {
38+
39+
urlObj.searchParams.delete(paramKey)
40+
// 使用HTML5的history API更新URL,不会触发页面刷新
41+
window.history.replaceState(null,document.title,urlObj.toString())
42+
}
43+
}
44+
}
45+
```

0 commit comments

Comments
 (0)