page.uvue 1.2 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
import { State, state, setLifeCycleNum } from '@/store/index.uts'
DCloud-WZF's avatar
DCloud-WZF 已提交
9
export default {
DCloud-WZF's avatar
DCloud-WZF 已提交
10 11 12 13 14
  data(){
    return {
      _state: state as State
    }
  },
DCloud-WZF's avatar
DCloud-WZF 已提交
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 48 49
  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
    },
DCloud-WZF's avatar
DCloud-WZF 已提交
50 51 52 53
    setLifeCycleNum(value: number) {
      // 自动化测试
      setLifeCycleNum(value)
    },
DCloud-WZF's avatar
DCloud-WZF 已提交
54 55 56
  },
}
</script>