page.uvue 2.0 KB
Newer Older
H
hdx 已提交
1
<template>
DCloud-WZF's avatar
DCloud-WZF 已提交
2
  <!-- #ifdef APP -->
3
  <scroll-view style="flex: 1" :bounces="false">
DCloud-WZF's avatar
DCloud-WZF 已提交
4
    <!-- #endif -->
5
    <view class="page container">
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">
15
import { 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)
  },
60 61 62 63
  onResize(_){
    // 自动化测试
    setLifeCycleNum(state.lifeCycleNum + 10)
  },
DCloud-WZF's avatar
DCloud-WZF 已提交
64
  methods: {
DCloud-WZF's avatar
DCloud-WZF 已提交
65 66
    // 自动化测试
    getLifeCycleNum() : number {
DCloud-WZF's avatar
DCloud-WZF 已提交
67 68
      return state.lifeCycleNum
    },
DCloud-WZF's avatar
DCloud-WZF 已提交
69 70 71 72
    // 自动化测试
    setLifeCycleNum(num : number) {
      setLifeCycleNum(num)
    },
73
    // 自动化测试
DCloud-WZF's avatar
DCloud-WZF 已提交
74 75 76 77 78 79 80 81 82 83 84 85 86
    pullDownRefresh() {
      uni.startPullDownRefresh({
        success() {
          setTimeout(() => {
            uni.stopPullDownRefresh()
          }, 1000)
        },
      })
    },
    scrollToBottom() {
      uni.pageScrollTo({
        scrollTop: 2000,
      })
DCloud-WZF's avatar
DCloud-WZF 已提交
87
    },
DCloud-WZF's avatar
DCloud-WZF 已提交
88 89 90
  },
}
</script>
DCloud-WZF's avatar
DCloud-WZF 已提交
91 92 93 94 95 96

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