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

需求:

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

效果:

步骤:

方法一:

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

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

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

方法二:

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

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

设置点击事件:

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

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

//退出小程序
 exitApplet() {
    wx.exitMiniProgram({
		success: function () {
		postCancelLogin({unique_id:this.unique_id}).then((res => {
			uni.removeStorageSync('iv'); //清除缓存	
		    uni.removeStorageSync('encryptedData');	
			}))
		}	
	}) 
}

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值