当前位置:网站首页>Wechat applet exits the applet (navigator and api--wx.exitminiprogram)

Wechat applet exits the applet (navigator and api--wx.exitminiprogram)

2022-06-26 04:41:00 Chu Junjun

demand :

In the wechat applet , Click on “ Cancel ” To exit the applet , Return to the wechat chat interface

effect :

step :

Method 1 :

Use it directly uni-app The components of ——navigator, Modify the parameters open-type="exit" target="miniProgram" that will do

( immediate withdrawal , No other action is required )

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

Method 2 :

Use wechat applet API--wx.exitMiniProgram

( For exit , Clear cache and other operations )

Set click event :

<view  @click="exitApplet()"> Cancel </view>

Set up api( stay success Function can be written to exit the applet , What to do )

// Exit applet 
 exitApplet() {
    wx.exitMiniProgram({
		success: function () {
		postCancelLogin({unique_id:this.unique_id}).then((res => {
			uni.removeStorageSync('iv'); // Clear cache 	
		    uni.removeStorageSync('encryptedData');	
			}))
		}	
	}) 
}

 

原网站

版权声明
本文为[Chu Junjun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206260432386979.html