page.uvue 1.0 KB
Newer Older
H
hdx 已提交
1
<template>
DCloud-WZF's avatar
DCloud-WZF 已提交
2 3 4
  <view class="page">
    <text>page lifecycle</text>
  </view>
H
hdx 已提交
5 6
</template>

H
hdx 已提交
7
<script>
DCloud-WZF's avatar
DCloud-WZF 已提交
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
import { state, setLifeCycleNum } from '@/store/index.uts'
export default {
  onLoad() {
    // 自动化测试
    setLifeCycleNum(state.lifeCycleNum + 100)
    console.log('Page onLoad')
  },
  onShow() {
    // 自动化测试
    setLifeCycleNum(state.lifeCycleNum + 10)
    console.log('Page onShow')
  },
  onReady() {
    // 自动化测试
    setLifeCycleNum(state.lifeCycleNum + 10)
    console.log('Page onReady')
  },
  onHide() {
    // 自动化测试
    setLifeCycleNum(state.lifeCycleNum - 10)
    console.log('Page onHide')
  },
  onUnload() {
    // 自动化测试
    setLifeCycleNum(state.lifeCycleNum - 100)
    console.log('Page onUnload')
  },
  onBackPress(options: OnBackPressOptions): boolean | null {
    // 自动化测试
    setLifeCycleNum(state.lifeCycleNum - 10)
    console.log('Page onBackPress from: ', options.from)
    return null
  },
  methods: {
    getLifeCycleNum(): number {
      return state.lifeCycleNum
    },
  },
}
</script>