小冯a
小冯a
  • 发布:2024-10-08 10:03
  • 更新:2024-10-09 14:00
  • 阅读:177

【报Bug】app $nextTick 偶发情况下不会执行

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: 专业版

HBuilderX类型: 正式

HBuilderX版本号: 4.29

手机系统: iOS

手机系统版本号: iOS 17

手机厂商: 苹果

手机机型: 随便

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:
复制代码    // 父组件  
   <confirmSeeContent  
      v-show="proress === 1"  
      ref="confirmSeeContent"  
      :detail="detail"  
      @onNext="onNext"  
    />  
    <confirmSubscribeContent  
      v-show="proress === 2"  
      :detail="detail"  
      :is-edit="isEdit"  
      ref="confirmSubscribeContent"  
    />  

        this.detail = reportInfoByIdAndType.data  
        this.isEdit = lookRepetitionCheck.data  
        this.$nextTick(() => {  
          this.$refs.confirmSeeContent.loadData()  
          this.$refs.confirmSubscribeContent.loadData()  
          this.loading = false  
        })  

// 子组件  
  props: {  
    detail: {  
      type: Object,  
      default: () => {}  
    }  
  },  
    loadData() {  
      if (this.detail.customerReportType !== 1 && this.detail.customerPhone.includes('*')) {  
        this.detail.customerPhone = ''  
      }  
      this.form = { ...this.detail }  
      this.loading = false  
    },  

操作步骤:

app 中 $nextTick 应当要执行

预期结果:

-

实际结果:

-

bug描述:

页面中 承载了两个子组件,由于子组件同时用到一笔接口数据,所以我在 页面得时候获取了接口数据,利用 props 传递给了子组件,传给子组件得值中,当我赋值完,马上又执行了子组件得方法,在子组件又用到了props 传递得数据,所以要用到 $nextTick ,但是 在app $nextTick 偶发情况下不会执行

2024-10-08 10:03 负责人:无 分享
已邀请:
BeardYound

BeardYound

是首次启动不执行还是切换页面再次调用不执行

  • 小冯a (作者)

    切换页面

    2024-10-11 09:17

  • BeardYound

    回复 小冯a: 确实是有这个问题,我记得我上次遇见这个问题还是几年前,后来给了一个保底方案就是这样,这个问题一般只出现在首页或tab栏切换

    if (!this.$refs.xx) {

    this.$nextTick(() => {

    this.$refs.xx.xx()

    })

    return

    }

    this.$refs.xx.xx()

    2024-10-11 09:42

  • 小冯a (作者)

    就没有什么加定时器解决不了的问题

    2024-10-22 11:58

要回复问题请先登录注册

  • 标题 / 粗斜体
  • 代码片段
  • 超链接 / 图片 / 视频
  • 列表 / 引用

文章内容较多时,可以用标题分段 :

## 大标题 
### 小标题

斜体 / 粗体 :

**粗体** 
*斜体*
***粗斜体***

代码片段 :

``` javascript
代码片段
```

超链接 :

[链接文字](链接地址) 例: [百度](http://www.baidu.com)

图片 :

![图片说明](图片地址) 例: ![百度logo](http://www.baidu.com/img/bdlogo.gif)

视频 :

!![视频说明](视频地址) 例: !![优酷视频](http://youku.com)

有序列表 :

1. 123
2. 123
3. 123

无序列表 :

- 123
- 123
- 123

引用 : ( 双回车后结束引用 )

> 引用内容
引用内容
引用内容