new-page-1.uvue 930 字节
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 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
<script lang="ts">
import { state } from '@/store/index.uts'
export default {
  data() {
    return {
      data: '',
    }
  },
  onLoad(options: OnLoadOptions) {
    if (options.has('data')) {
      this.data = options.get('data')!
    }
  },
  methods: {
    // 自动化测试
    getLifeCycleNum(): number {
      return state.lifeCycleNum
    },
DCloud-WZF's avatar
DCloud-WZF 已提交
30 31 32 33 34 35 36 37 38 39 40
    navigateBackWithDelta2() {
      uni.navigateBack({
        delta: 2,
        success() {
          console.log('回退上上层页面成功')
        },
        fail(error) {
          console.warn(`回退上上层页面失败: ${error.errMsg}`)
        },
      })
    },
DCloud-WZF's avatar
DCloud-WZF 已提交
41 42 43
  },
}
</script>