new-page-1.uvue 1.2 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
<template>
  <page-head title="new-page-1" />
  <view class="uni-padding-wrap">
    <text>onLoad 接收到参数</text>
    <text>data: {{ data }}</text>
    <button @tap="navigateBackWithDelta2" class="uni-btn">
      回退到上上层页面
    </button>
  </view>
</template>

<script lang="uts">
  import { state } from '@/store/index.uts'

  export default {
    data() {
      return {
        data: '',
      }
    },
    onLoad(options : OnLoadOptions) {
      if (options['data'] != null) {
        this.data = options['data']!
      }
    },
    methods: {
      // 自动化测试
      getLifeCycleNum() : number {
        return state.lifeCycleNum
      },
      navigateBackWithDelta2() {
        uni.navigateBack({
          delta: 2,
          success() {
            console.log('回退上上层页面成功')
          },
          fail(error) {
            console.warn(`回退上上层页面失败: ${error.errMsg}`)
          },
        })
      },
      navigateToOnLoadWithType(type : string) {
        uni.navigateTo({
          url: `/pages/API/navigator/new-page/onLoad?type=${type}`,
        })
      }
    },
  }
DCloud-WZF's avatar
DCloud-WZF 已提交
49
</script>