李承武

uni-app报错:undefined is not an object (evaluating 'obj[key]');

开发Android报错,H5没问题,IOS和各小程序没测,根据这位兄弟的反馈,估计只在APP里报这错。。。

我是在嵌套的v-for循环绑定tap事件传参报错,不嵌套的v-for绑定tap事件传参没问题。

解决办法:改用navigator组件来传参

tap事件传参报错代码

<swiper-item v-for="(item, tabbarIdx) in tabbar" :key="tabbarIdx">
  <scroll-view scroll-y class="scoll-y" @scrolltolower="onBottom">
    <view class="vod-list">
      <view class="vod-list-item" v-for="(vod, index) in vods.vodlist[tabbarIdx + 1].data" :key="index" @tap="vodPlay(vod.id)">
        <view class="vod-list-box">
          <image mode="aspectFill" lazy-load="true" class="vod-list-img" :src="`https://localhost/${vod.d_pic}`"></image>
        </view>
        <view class="vod-list-title">{{ vod.d_name }}</view></view>
    </view>
  </scroll-view>
</swiper-item>
<swiper-item v-for="(item, tabbarIdx) in tabbar" :key="tabbarIdx">
  <scroll-view scroll-y class="scoll-y" @scrolltolower="onBottom">
    <view class="vod-list">
      <view class="vod-list-item" v-for="(vod, index) in vods.vodlist[tabbarIdx + 1].data" :key="index">
        <navigator :url="`../vodplay/vodplay?id=${vod.id}`">
          <view class="vod-list-box">
            <image mode="aspectFill" lazy-load="true" class="vod-list-img" :src="`https://localhost/${vod.d_pic}`"></image>
          </view>
          <view class="vod-list-title">{{ vod.d_name }}</view>
        </navigator>
      </view>
    </view>
  </scroll-view>
</swiper-item>

enjoy life

评论