get-app.uvue 771 字节
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1
<template>
DCloud-WZF's avatar
DCloud-WZF 已提交
2 3 4 5 6 7 8
  <view>
    <page-head title="getApp"></page-head>
    <view class="uni-padding-wrap">
      <button @click="_increasetLifeCycleNum">increase lifeCycleNum</button>
      <text class="uni-common-mt">lifeCycleNum: {{ lifeCycleNum }}</text>
    </view>
  </view>
DCloud-WZF's avatar
DCloud-WZF 已提交
9
</template>
DCloud-WZF's avatar
DCloud-WZF 已提交
10
<script lang="ts">
DCloud-WZF's avatar
DCloud-WZF 已提交
11
import { state, setLifeCycleNum } from '@/store/index.uts'
DCloud-WZF's avatar
DCloud-WZF 已提交
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
export default {
  data() {
    return {
      lifeCycleNum: 0,
    }
	},
	onReady() {
		this.lifeCycleNum = state.lifeCycleNum
	},
  methods: {
    _increasetLifeCycleNum: function () {
      const app = getApp()
      app.increasetLifeCycleNum()
      this.lifeCycleNum = state.lifeCycleNum
    },
DCloud-WZF's avatar
DCloud-WZF 已提交
27 28 29 30
    // 自动化测试
    setLifeCycleNum(num: number) {
      setLifeCycleNum(num)
    },
DCloud-WZF's avatar
DCloud-WZF 已提交
31 32
  },
}
DCloud-WZF's avatar
DCloud-WZF 已提交
33
</script>