uniapp退出关闭当前小程序或APP

使用场景:进入小程序/APP有隐私协议,点击不同意隐私协议退出小程序/APP

一、退出当前小程序

<navigator open-type="exit" target="miniProgram">退出</navigator>

二、小程序由APP跳转而来,点击按钮退回APP

<button open-type="launchApp" app-parameter="wechat" binderror="launchAppError">退出</button>

navigator

页面跳转。
该组件类似HTML中的< a >组件,但只能跳转本地页面。目标页面必须在pages.json中注册。

属性:

属性名类型默认值说明平台差异说明
urlString-应用内的跳转链接,值为相对路径或绝对路径,如:“…/first/first”,“/pages/first/first”,注意不能加 .vue 后缀-
open-typeStringnavigate跳转方式-
deltaNumber-当 open-type 为 ‘navigateBack’ 时有效,表示回退的层数-
animation-typeStringpop-in/out当 open-type 为 navigate、navigateBack 时有效,窗口的显示/关闭动画效果App
animation-durationNumber300当 open-type 为 navigate、navigateBack 时有效,窗口显示/关闭动画的持续时间。App
hover-classStringnavigator-hover指定点击时的样式类,当hover-class="none"时,没有点击态效果-
hover-stop-propagationBooleanfalse指定是否阻止本节点的祖先节点出现点击态微信小程序
hover-start-timeNumber50按住后多久出现点击态,单位毫秒-
hover-stay-timeNumber600手指松开后点击态保留时间,单位毫秒-
targetStringself在哪个小程序目标上发生跳转,默认当前小程序,值域self/miniProgram微信2.0.7+、百度2.5.2+、QQ

open-type 有效值

说明平台差异说明
navigate对应 uni.navigateTo 的功能-
redirect对应 uni.redirectTo 的功能-
switchTab对应 uni.switchTab 的功能-
reLaunch对应 uni.reLaunch 的功能字节跳动小程序与飞书小程序不支持
navigateBack对应 uni.navigateBack 的功能-
exit退出小程序,target="miniProgram"时生效微信2.1.0+、百度2.5.2+、QQ1.4.7+

官方文档:https://uniapp.dcloud.net.cn/component/navigator.html#navigator

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
uniapp中,要实现退出app的功能,可以使用open-type属性来控制退出行为。根据引用\[1\]中的内容,有两种方法可以实现退出app的功能。 第一种方法是在小程序中使用<navigator>标签,并设置open-type属性为"exit",如下所示: ``` <navigator open-type="exit" target="miniProgram">退出</navigator> ``` 这样当用户点击退出按钮时,小程序退出。 第二种方法是在小程序中使用<button>标签,并设置open-type属性为"launchApp",并通过app-parameter属性指定要跳转的app,如下所示: ``` <button open-type="launchApp" app-parameter="wechat" binderror="launchAppError">退出</button> ``` 这样当用户点击退出按钮时,小程序会跳转到指定的app。 另外,根据引用\[2\]中的内容,如果你想在uniapp中实现类似于重写返回方法让app退出而是进入后台运行的功能,你可以在main.js中修改plus.runtime.quit()方法。具体的代码可以参考引用\[2\]中的示例代码。 总结起来,要在uniapp中实现退出app的功能,可以使用open-type属性来控制退出行为,或者通过修改plus.runtime.quit()方法来实现自定义的退出逻辑。 #### 引用[.reference_title] - *1* *3* [uniapp退出关闭当前小程序APP](https://blog.csdn.net/Kino_Hs/article/details/126866661)[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^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [uniapp自定义应用退出执行内容](https://blog.csdn.net/Mr_Bobcp/article/details/125876986)[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^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值