9433cfb9创建于 2025年12月31日历史提交
<template>
  <page-head title="new-page-1" />
  <share-element share-key="test-share-element-key">
    <image style="width: 250px; height: 176px;" src="/static/shuijiao.jpg" mode="scaleToFill"></image>
  </share-element>
  <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: '',
        checked: false
      }
    },
    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}`,
        })
      }
    },
  }
</script>