head-img Force's Blog

Uniapp开发web移动端和微信小程序,v-for在web移动端正确输出,但在微信小程序下循环值为undefind

JavaScript

Uniapp开发web移动端和微信小程序,v-for在web移动端正确输出,但在微信小程序下循环值为undefind

问题代码片段:

  <view>技能:
    <text class="item mr15" v-for="(item, index) in wrap.json_data.resume_skill.content.skills" :key="index">
      {{ item.val }}
    </text>
  </view>

  <view>兴趣:
    <text class="item mr15" v-for="(item, index) in wrap.json_data.resume_skill.content.hobbies" :key="index">
      {{ item.val }}
    </text>
  </view>

问题根源是因为元素上class="item"导致的,将v-foritem修改为value即可。
猜测可能是uniapp在小程序编译过程有bug导致

修改代码片段:

  <view>技能:
    <text class="item mr15" v-for="(value, index) in wrap.json_data.resume_skill.content.skills" :key="index">
      {{ value.val }}
    </text>
  </view>

  <view>兴趣:
    <text class="item mr15" v-for="(value, index) in wrap.json_data.resume_skill.content.hobbies" :key="index">
      {{ value.val }}
    </text>
  </view>
点我评论
打赏本文
二维码


125

文章

14

标签

 访客统计  Update-******