new-page-1.uvue 938 字节
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: Map<string, string>) {
DCloud-WZF's avatar
DCloud-WZF 已提交
22 23 24 25 26 27 28 29 30
    if (options.has('data')) {
      this.data = options.get('data')!
    }
  },
  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}`)
        },
      })
    },
DCloud-WZF's avatar
DCloud-WZF 已提交
42 43 44
  },
}
</script>