on-back-press-options.uvue 769 字节
Newer Older
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
<template>
  <view class="page container">
    <text>测试 onBackPress 生命周期返回 true</text>
    <button class='mt-10' @click="goChildPage">跳转子页,测试返回值为 false</button>
  </view>
</template>

<script lang='uts'>
  export default {
    data() {
      return {
        backPressOptions: {
          from: 'backbutton'
        } as OnBackPressOptions
      }
    },
    onBackPress(options: OnBackPressOptions): boolean | null {
      console.log('onBackPress', options)
      this.backPressOptions = options
      return true
    },
    methods: {
      goChildPage() {
        uni.navigateTo({
          url: '/pages/lifecycle/page/onBackPress/on-back-press-child-options'
        })
      }
    }
  }
</script>