onBackPress((options) => {
  console.log('from:' + options.from)
  if (options.from === 'navigateBack') {
    return false
  }
  if (flag.value == 'edit') {
    uni.navigateBack({})
    return true
  } else if (flag.value == 'add') {
    uni.showModal({
      title: '提示',
      content: `暂未保存报告单信息,请确定要继续吗?`,
      success: function (res) {
        if (res.confirm) {
          uni.navigateBack({ delta: 2 })
        } else if (res.cancel) {
        }
      },
    })
    return true
  }
})

https://ask.dcloud.net.cn/article/35120

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐