Lifecycle.uvue 1.6 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1
<template>
DCloud-WZF's avatar
DCloud-WZF 已提交
2 3 4
  <view>
    <text>{{ title }}</text>
  </view>
DCloud-WZF's avatar
DCloud-WZF 已提交
5 6 7 8 9
</template>

<script lang="ts">
import { state, setLifeCycleNum } from '../store/index.uts'
export default {
DCloud-WZF's avatar
DCloud-WZF 已提交
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61
  name: 'ComponentLifecycle',
  data() {
    return {
      title: 'component for lifecycle test',
    }
  },
  beforeCreate() {
    // 自动化测试
    setLifeCycleNum(state.lifeCycleNum + 1)
    console.log('component for lifecycle test beforeCreate')
  },
  created() {
    // 自动化测试
    setLifeCycleNum(state.lifeCycleNum + 1)
    console.log('component for lifecycle test created')
  },
  beforeMount() {
    // 自动化测试
    setLifeCycleNum(state.lifeCycleNum + 1)
    console.log('component for lifecycle test beforeMount')
  },
  mounted() {
    // 自动化测试
    setLifeCycleNum(state.lifeCycleNum + 1)
    console.log('component for lifecycle test mounted')
  },
  beforeUpdate() {
    // 自动化测试
    setLifeCycleNum(state.lifeCycleNum + 1)
    console.log('component for lifecycle test beforeUpdate')
  },
  updated() {
    // 自动化测试
    setLifeCycleNum(state.lifeCycleNum + 1)
    console.log('component for lifecycle test updated')
  },
  beforeUnmount() {
    // 自动化测试
    setLifeCycleNum(state.lifeCycleNum - 1)
    console.log('component for lifecycle test beforeUnmount')
  },
  unmounted() {
    // 自动化测试
    setLifeCycleNum(state.lifeCycleNum - 1)
    console.log('component for lifecycle test unmounted')
  },
  methods: {
    // 自动化测试
    getLifeCycleNum(): number {
      return state.lifeCycleNum
    },
  },
DCloud-WZF's avatar
DCloud-WZF 已提交
62 63
}
</script>