请选择 进入手机版 | 继续访问电脑版
 找回密码
 立即注册
搜索

【审核】【技术】for循环,list[index].head报错审核不通过

5
回复
2918
查看
[复制链接]

4

主题

9

帖子

65

积分

 楼主| 2018-5-21 15:25:36 显示全部楼层 |阅读模式
报错如下
  1. [code]undefined:132: TypeError: Cannot read property 'head' of undefined
  2. TypeError: Cannot read property 'head' of undefined
  3. at e.module.exports.children.children.children.children.attr.src (eval at ur (unknown source), <anonymous>:132:70)
  4. at rc.get (<anonymous>:4:1578)
  5. at rc.update (<anonymous>:4:2151)
  6. at Ys.notify (<anonymous>:4:124)
  7. at Object.defineProperty.set [as list] (<anonymous>:1:20255)
  8. at <anonymous>:1:22177
  9. at e.<anonymous> (<anonymous>:1:27590)
  10. at rc.update (<anonymous>:4:2220)
  11. at Ys.notify (<anonymous>:4:124)
  12. at Object.defineProperty.set [as hot] (<anonymous>:1:20255)
  13. com.eclipsesource.v8.V8ScriptExecutionException
复制代码
代码如下:
  1. <block for="{{(index, value) in list}}" if="{{index%3===0}}">
  2. <list-item type="product" class="content-item">
  3. <div class="item-info" if="{{list[index].head}}">
  4. <img src="{{list[index].head}}" alt="" class="img-head" @click="{{headClick(list[index])}}">
  5. <text class="text-name">{{list[index].nickname}}</text>
  6. </div>
  7. <div class="item-info" if="{{list[index+1] && list[index+1].head}}">
  8. <img src="{{list[index+1].head}}" alt="" class="img-head" @click="{{headClick(list[index+1])}}">
  9. <text class="text-name">{{list[index+1].nickname}}</text>
  10. </div>
  11. <div class="item-info" if="{{list[index+2] && list[index+2].head}}">
  12. <img src="{{list[index+2].head}}" alt="" class="img-head" @click="{{headClick(list[index+2])}}">
  13. <text class="text-name">{{list[index+2].nickname}}</text>
  14. </div>
  15. </list-item>
  16. </block>
复制代码
报错的原因是list[index]为undefined,但是通过if,判断list[index]存在之后才会执行,报错之后不影响页面渲染及功能使用,请问如何避免使用下一个索引引用时不报错
回复

使用道具 举报

4

主题

9

帖子

65

积分

 楼主| 2018-5-23 09:43:26 显示全部楼层
没人吗,怎么@官方的人,莫名其妙的报错
回复

使用道具 举报

0

主题

8

帖子

40

积分

2018-6-7 16:34:48 显示全部楼层
楼主问题解决了吗?如还没找到解决方案,欢迎加入Flyme 快应用开发者交流群:471543256 方便问题的解决
回复

使用道具 举报

0

主题

8

帖子

40

积分

2018-6-21 15:39:54 显示全部楼层
代码信息暂不能确认报错问题的原因哦,需要list数据结构信息和相关上下文信息再行判断,欢迎加入Flyme 快应用开发者交流群:471543256 方便问题的解决,谢谢支持!
回复

使用道具 举报

4

主题

9

帖子

65

积分

 楼主| 2018-7-12 17:14:11 显示全部楼层
魅族快应用官方 发表于 2018-6-21 15:39 代码信息暂不能确认报错问题的原因哦,需要list数据结构信息和相关上下文信息再行判断,欢迎加入Flyme 快应 ...
过审了,通过数组下标引用才报错,谢谢回复

点评

好的呢,后续还有其他问题欢迎咨询  详情 回复 发表于 2018-7-31 16:04
回复

使用道具 举报

0

主题

8

帖子

40

积分

2018-7-31 16:04:56 显示全部楼层
sammiya 发表于 2018-7-12 17:14 过审了,通过数组下标引用才报错,谢谢回复
好的呢,后续还有其他问题欢迎咨询
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册