微信小程序点击强制退出

在微信小程序api中有这样一个组件

navigator: 页面链接

open-type string navigate 跳转方式

open-type 的合法值

说明最低版本
navigate 对应 wx.navigateTo 或 wx.navigateToMiniProgram 的功能  
redirect 对应 wx.redirectTo 的功能  
switchTab 对应 wx.switchTab 的功能  
reLaunch 对应 wx.reLaunch 的功能 1.1.0
navigateBack 对应 wx.navigateBack 的功能 1.1.0
exit 退出小程序,target="miniProgram"时生效 2.1.0

上面是微信小程序官方给的文档

然后再来看我们的代码如何实现其实很简单就一行代码

    <navigator id="submitBtn" class="ui-btn" open-type="exit" target="miniProgram" style="left:100px;" bindtap="out" > 点此退出 </navigator>

只要在wxml中在的navigator中加上属性open-type="exit"并且需要加上 target="miniProgram"点击一下就会直接强制退出才会生效

posted @ 2020-05-07 11:01  Ferocious  阅读(1674)  评论(0编辑  收藏  举报