App.vue 994 字节
Newer Older
1
<!-- HBuilder X 版本要求: 3.6.11+ -->
DCloud-WZF's avatar
DCloud-WZF 已提交
2
<script lang="ts">
3
let firstBackTime = 0
4 5
export default {
  onLaunch: function () {
6
    console.log('App Launch')
7 8
  },
  onShow: function () {
9
    console.log('App Show')
10 11
  },
  onHide: function () {
12
    console.log('App Hide')
13
  },
14
  onLastPageBackPress: function () {
15
    // #ifdef UNI-APP-X && APP-ANDROID
DCloud-WZF's avatar
DCloud-WZF 已提交
16
    console.log('App LastPageBackPress')
17 18 19 20 21 22 23 24 25 26 27
    if (firstBackTime == 0) {
      uni.showToast({
        title: '再按一次退出应用',
        position: 'bottom',
      })
      firstBackTime = Date.now()
      setTimeout(() => {
        firstBackTime = 0
      }, 2000)
    } else if (Date.now() - firstBackTime < 2000) {
      firstBackTime = Date.now()
DCloud-WZF's avatar
DCloud-WZF 已提交
28
      uni.exit()
29
    }
30
    // #endif
31
  },
DCloud-WZF's avatar
DCloud-WZF 已提交
32 33 34
  onExit() {
    console.log('App Exit')
  },
35
}
杜庆泉's avatar
init  
杜庆泉 已提交
36 37 38
</script>

<style>
39 40 41 42 43
/*每个页面公共css */
/* uni.css - 通用组件、模板样式库,可以当作一套ui库应用 */
/* #ifdef APP-VUE */
@import './common/uni.css';
/* #endif */
杜庆泉's avatar
init  
杜庆泉 已提交
44
</style>