本文最后更新于 2024-11-14,文章内容可能已经过时。

小程序wxml页面:

<view>
   <button bindtap="clear">退出登录</button>
</view>

小程序js页面

//清除缓存
 
 clear:function(){
    wx.clearStorageSync();//清除缓存
    wx.showToast({
       title: '退出登录成功',
       icon: 'none',
       duration: 2000,
       success: function () {
          setTimeout(function () {
             //跳转到首页,强制重启
             wx.reLaunch({
                url: '/pages/index/index',
             })
          }, 2000);
       }
    })
},