大冰凌
大冰凌
  • 发布:2025-09-16 14:56
  • 更新:2025-09-16 15:18
  • 阅读:38

uniapp开发的微信小程序,子页面保存返回父页面的时候,希望在父页面做提示,目前提示在Android上有,但在iOS上没有,这个是什么问题

分类:uni-app

uniapp开发的微信小程序,子页面保存返回父页面的时候,希望在父页面做提示,目前提示在Android上有,但在iOS上没有,这个是什么问题?用了全局事件总线写法和页面通信写法,效果均为Android有提示,ios没有

全局事件总线代码如下:
子页面:```javascript
uni.$emit('initPage', status)
uni.navigateBack({
delta: -1
})


父页面:
```javascript  
if (status) {  
          // 延迟显示toast,确保页面切换完成后再显示  
          setTimeout(() => {  
            if (this.pageSearchData.audit !== '') {  
              uni.showToast({  
                title: status == 1 ? '操作成功, 可通过筛选找到已通过的患者' : '操作成功, 可通过筛选找到已拒绝的患者',  
                icon: 'none',  
                duration: 3000  
              })  
            } else {  
              uni.showToast({  
                title: '操作成功',  
                icon: 'none',  
                duration: 3000  
              })  
            }  
          }, 100) // 增加延迟时间,确保在iOS上也能正常显示  
        }
2025-09-16 14:56 负责人:无 分享
已邀请:
DCloud_UNI_JBB

DCloud_UNI_JBB

什么版本的hx?麻烦发下可复现demo

  • 大冰凌 (作者)

    版本: 2.0.0-25120200103006


    子页面在点击按钮后调用


    async checkStatus(status) {

    const res = await this.$http.get(/patientFilter/audit/${this.patientId}, {

    status

    })

    if (res && res.code == 200) {

    // 操作成功后,父页面重新请求

    uni.$emit('initPage', status)

    uni.navigateBack({

    delta: -1

    })

    }

    },


    父页面 onLoad内有 uni.$on('initPage', this.initPage)

    对应触发事件如下:

    initPage(status) {

    console.log(status, this.pageSearchData.audit, 'status++++')

    if (status) {

    // 延迟显示toast,确保页面切换完成后再显示

    setTimeout(() => {

    if (this.pageSearchData.audit !== '') {

    uni.showToast({

    title: status == 1 ? '操作成功, 可通过筛选找到已通过的患者' : '操作成功, 可通过筛选找到已拒绝的患者',

    icon: 'none',

    duration: 3000

    })

    } else {

    uni.showToast({

    title: '操作成功',

    icon: 'none',

    duration: 3000

    })

    }

    }, 100) // 增加延迟时间,确保在iOS上也能正常显示

    }

    this.clear()

    this.getPatientCheckList()

    },

    2025-09-16 15:19

  • DCloud_UNI_JBB

    回复 大冰凌: 同样的代码,测试一下原生微信小程序有没有这个问题

    2025-09-16 15:23

  • 大冰凌 (作者)

    回复 DCloud_UNI_JBB: 不大方便,我去微信开放文档溜达一圈

    2025-09-16 15:29

要回复问题请先登录注册