Uniapp退出应用
App
if (uni.getSystemInfoSync().platform == 'ios'){ plus.ios.import("UIApplication").sharedApplication().performSelector("exit") } else if (uni.getSystemInfoSync().platform == 'android'){ plus.runtime.quit(); }
微信小程序平台
<navigator target="miniProgram" open-type="exit">退出小程序</navigator>
Android 注意:iOS 平台不支持此 API。
plus.runtime.quit();
iOS
const threadClass = plus.ios.importClass("NSThread"); const mainThread = plus.ios.invoke(threadClass, "mainThread"); plus.ios.invoke(mainThread, "exit"); //上面的不行就用下面的 plus.ios.import("UIApplication").sharedApplication().performSelector("exit")