page.uvue 1.8 KB
Newer Older
H
hdx 已提交
1
<template>
DCloud-WZF's avatar
DCloud-WZF 已提交
2 3 4
  <!-- #ifdef APP -->
  <scroll-view style="flex: 1">
    <!-- #endif -->
DCloud-WZF's avatar
DCloud-WZF 已提交
5
    <view class="page">
DCloud-WZF's avatar
DCloud-WZF 已提交
6
      <text>page lifecycle</text>
DCloud-WZF's avatar
DCloud-WZF 已提交
7
      <button class="uni-common-mt" @click="scrollToBottom">scrollToBottom</button>
DCloud-WZF's avatar
DCloud-WZF 已提交
8 9 10 11
    </view>
    <!-- #ifdef APP -->
  </scroll-view>
  <!-- #endif -->
H
hdx 已提交
12 13
</template>

DCloud-WZF's avatar
DCloud-WZF 已提交
14
<script lang="uts">
DCloud-WZF's avatar
DCloud-WZF 已提交
15
import { State, state, setLifeCycleNum } from '@/store/index.uts'
DCloud-WZF's avatar
DCloud-WZF 已提交
16

DCloud-WZF's avatar
DCloud-WZF 已提交
17
export default {
DCloud-WZF's avatar
DCloud-WZF 已提交
18
  data() {
DCloud-WZF's avatar
DCloud-WZF 已提交
19
    return {
DCloud-WZF's avatar
DCloud-WZF 已提交
20
      isScrolled: false,
DCloud-WZF's avatar
DCloud-WZF 已提交
21 22
    }
  },
DCloud-WZF's avatar
DCloud-WZF 已提交
23
  onLoad(_ : OnLoadOptions) {
DCloud-WZF's avatar
DCloud-WZF 已提交
24 25 26 27 28 29 30 31 32 33 34
    // 自动化测试
    setLifeCycleNum(state.lifeCycleNum + 100)
  },
  onShow() {
    // 自动化测试
    setLifeCycleNum(state.lifeCycleNum + 10)
  },
  onReady() {
    // 自动化测试
    setLifeCycleNum(state.lifeCycleNum + 10)
  },
DCloud-WZF's avatar
DCloud-WZF 已提交
35
  onPullDownRefresh() {
DCloud-WZF's avatar
DCloud-WZF 已提交
36
    // 自动化测试
DCloud-WZF's avatar
DCloud-WZF 已提交
37
    setLifeCycleNum(state.lifeCycleNum + 10)
DCloud-WZF's avatar
DCloud-WZF 已提交
38
  },
DCloud-WZF's avatar
DCloud-WZF 已提交
39
  onPageScroll(_) {
DCloud-WZF's avatar
DCloud-WZF 已提交
40
    // 自动化测试
DCloud-WZF's avatar
DCloud-WZF 已提交
41
    this.isScrolled = true
DCloud-WZF's avatar
DCloud-WZF 已提交
42
  },
DCloud-WZF's avatar
DCloud-WZF 已提交
43 44 45 46 47
  onReachBottom() {
    // 自动化测试
    setLifeCycleNum(state.lifeCycleNum + 10)
  },
  onBackPress(_ : OnBackPressOptions) : boolean | null {
DCloud-WZF's avatar
DCloud-WZF 已提交
48 49 50 51
    // 自动化测试
    setLifeCycleNum(state.lifeCycleNum - 10)
    return null
  },
DCloud-WZF's avatar
DCloud-WZF 已提交
52 53 54 55 56 57 58 59
  onHide() {
    // 自动化测试
    setLifeCycleNum(state.lifeCycleNum - 10)
  },
  onUnload() {
    // 自动化测试
    setLifeCycleNum(state.lifeCycleNum - 100)
  },
DCloud-WZF's avatar
DCloud-WZF 已提交
60
  methods: {
DCloud-WZF's avatar
DCloud-WZF 已提交
61 62
    // 自动化测试
    getLifeCycleNum() : number {
DCloud-WZF's avatar
DCloud-WZF 已提交
63 64
      return state.lifeCycleNum
    },
DCloud-WZF's avatar
DCloud-WZF 已提交
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
    // 自动化测试
    setLifeCycleNum(num : number) {
      setLifeCycleNum(num)
    },
    pullDownRefresh() {
      uni.startPullDownRefresh({
        success() {
          setTimeout(() => {
            uni.stopPullDownRefresh()
          }, 1000)
        },
      })
    },
    scrollToBottom() {
      uni.pageScrollTo({
        scrollTop: 2000,
      })
DCloud-WZF's avatar
DCloud-WZF 已提交
82
    },
DCloud-WZF's avatar
DCloud-WZF 已提交
83 84 85
  },
}
</script>
DCloud-WZF's avatar
DCloud-WZF 已提交
86 87 88 89 90 91

<style>
.container {
  height: 1200px;
}
</style>