如果应用程序关闭或应用程序是否发送到后台,我如何在 Ionic Vue 中检测?
this.platform
或platform
不可用或不起作用?!
如果应用程序关闭或应用程序是否发送到后台,我如何在 Ionic Vue 中检测?
this.platform
或platform
不可用或不起作用?!
您可以订阅该appStateChange
事件,如下所述:https ://capacitorjs.com/docs/apis/app
例子:
import { App } from '@capacitor/app'
export default {
created () {
App.addListener('appStateChange', state => {
if (!state.isActive) { // if isActive is true, App got sent to foreground, if it is false, it got sent to the background
...
}
})
}
}