new-page-1.uvue 1.1 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1 2
<template>
  <view class="uni-padding-wrap">
DCloud-WZF's avatar
DCloud-WZF 已提交
3
    <page-head title="new-page-1" />
DCloud-WZF's avatar
DCloud-WZF 已提交
4 5
    <text>onLoad 接收到参数</text>
    <text>data: {{ data }}</text>
DCloud-WZF's avatar
DCloud-WZF 已提交
6 7 8
    <button @tap="navigateBackWithDelta2" class="uni-btn">
      回退到上上层页面
    </button>
DCloud-WZF's avatar
DCloud-WZF 已提交
9 10
  </view>
</template>
DCloud-WZF's avatar
DCloud-WZF 已提交
11

DCloud-WZF's avatar
DCloud-WZF 已提交
12
<script lang="uts">
DCloud-WZF's avatar
DCloud-WZF 已提交
13
import { state } from '@/store/index.uts'
DCloud-WZF's avatar
DCloud-WZF 已提交
14

DCloud-WZF's avatar
DCloud-WZF 已提交
15 16 17 18 19 20
export default {
  data() {
    return {
      data: '',
    }
  },
DCloud-WZF's avatar
DCloud-WZF 已提交
21
  onLoad(options: OnLoadOptions) {
雪洛's avatar
雪洛 已提交
22 23
    if (options['data'] != null) {
      this.data = options['data']
DCloud-WZF's avatar
DCloud-WZF 已提交
24 25 26 27 28 29 30
    }
  },
  methods: {
    // 自动化测试
    getLifeCycleNum(): number {
      return state.lifeCycleNum
    },
DCloud-WZF's avatar
DCloud-WZF 已提交
31 32 33 34 35 36 37 38 39 40 41
    navigateBackWithDelta2() {
      uni.navigateBack({
        delta: 2,
        success() {
          console.log('回退上上层页面成功')
        },
        fail(error) {
          console.warn(`回退上上层页面失败: ${error.errMsg}`)
        },
      })
    },
42 43 44 45 46
    navigateToOnLoadWithType(type: string) {
      uni.navigateTo({
        url: `/pages/API/navigator/new-page/onLoad?type=${type}`,
      })
    }
DCloud-WZF's avatar
DCloud-WZF 已提交
47 48 49
  },
}
</script>