微信小程序點擊強制退出


在微信小程序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"點擊一下就會直接強制退出才會生效


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM