Open MXHanner opened 5 years ago
大佬,微信小程序购物车界面不显示任何内容了为什么呀,Console报错 Uncaught (in promise) TypeError: Cannot read property 'images' of null at index.js:44 at Array.forEach () at index.js:44 at 我点开index.js,Sources标注pages/cart/index.js下面最长的那一句后面括号里错误: getCarts() { App.HttpService.getCartByUser() .then(res => { const data = res.data console.log(data) if (data.meta.code == 0) { data.data.forEach(n => n.goods.thumb_url = App.renderImage(n.goods.images[0] && n.goods.images[0].path)) this.setData({ 'carts.items': data.data, 'prompt.hidden': data.data.length, }) } }) }, 是因为我把后端的数据都换掉了吗[/害怕]
我把data.data.forEach(n => n.goods.thumb_url = App.renderImage(n.goods.images[0] && n.goods.images[0].path))给注释掉了就可以显示页面了,但是就没有图片了
大佬,微信小程序购物车界面不显示任何内容了为什么呀,Console报错 Uncaught (in promise) TypeError: Cannot read property 'images' of null at index.js:44 at Array.forEach ()
at index.js:44
at
我点开index.js,Sources标注pages/cart/index.js下面最长的那一句后面括号里错误:
getCarts() {
App.HttpService.getCartByUser()
.then(res => {
const data = res.data
console.log(data)
if (data.meta.code == 0) {
data.data.forEach(n => n.goods.thumb_url = App.renderImage(n.goods.images[0] && n.goods.images[0].path))
this.setData({
'carts.items': data.data,
'prompt.hidden': data.data.length,
})
}
})
},
是因为我把后端的数据都换掉了吗[/害怕]