uniapp禁止侧滑
时间: 2023-08-08 10:12:04 浏览: 193
侧滑返回
在uniapp中禁止侧滑可以通过在pages.json文件中的style属性中设置"disableSwipeBack": true来实现。具体的配置如下所示:
```json
{
"path": "pages/chat/index",
"style": {
"disableSwipeBack": true
}
}
```
此配置将禁止在该页面中进行侧滑返回操作。\[1\]
另外,你也可以在manifest.json文件中的plus节点下配置"popGesture": "none"来禁止响应左滑动画。具体配置如下所示:
```json
"plus": {
"popGesture": "none"
}
```
这样配置后,整个uniapp项目都将禁止侧滑返回操作。\[2\]
如果你只想在单个页面中禁止侧滑返回,可以使用以下代码:
```javascript
// #ifdef APP-PLUS
let pages = getCurrentPages();
let page = pages\[pages.length - 1\];
let currentWebview = page.$getAppWebview()
currentWebview.setStyle({ popGesture: 'none' })
// #endif
```
这段代码将禁止当前页面的侧滑返回操作。\[2\]
你可以参考uniapp官方文档中的manifest.json配置和5+ API调用来获取更多关于禁止侧滑的信息。\[3\]
#### 引用[.reference_title]
- *1* [亲测,解决uni-app禁止IOS侧滑“popGesture“: “none“ 失效](https://blog.csdn.net/weixin_44668640/article/details/125678133)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [uniapp怎么关闭侧滑](https://blog.csdn.net/dct1130/article/details/117076219)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [uniapp禁止单页面侧滑返回](https://blog.csdn.net/qq_31754523/article/details/107456335)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文