• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

#微信小程序# 在小程序里面退出退出小程序navigator以和API--wx.exitMiniProgram

武飞扬头像
Miraitowa_chole
帮助1

需求:

在微信小程序里面,点击“取消”字样即可退出小程序,返回微信聊天界面

效果:

学新通

步骤:

方法一:

直接使用uni-app的组件——navigator,修改参数open-type="exit" target="miniProgram"即可

(直接退出,不需要执行其他操作)

 <navigator open-type="exit" target="miniProgram" >取消</navigator> 

方法二:

使用微信小程序API--wx.exitMiniProgram

(适用于退出时,清除缓存等操作)

设置点击事件:

<view  @click="exitApplet()">取消</view>

设置api(在success函数里面可以写入一些退出小程序时,要执行的操作)

  1.  
    //退出小程序
  2.  
    exitApplet() {
  3.  
    wx.exitMiniProgram({
  4.  
    success: function () {
  5.  
    postCancelLogin({unique_id:this.unique_id}).then((res => {
  6.  
    uni.removeStorageSync('iv'); //清除缓存
  7.  
    uni.removeStorageSync('encryptedData');
  8.  
    }))
  9.  
    }
  10.  
    })
  11.  
    }

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgfijff
系列文章
更多 icon
同类精品
更多 icon
继续加载