html52.com
我爱小程序-开发者交流社区

怎么遍历never数组?就是得到【0】里面的_id、goods_price等等

网友回复

小猪快跑:

in是索引,of才是对象呀

for(let item of that.cart){

console.log(item.goods_price,item.goods_name)

}

Charlie:
console.log(that.cart[v])
console.log(that.cart[v]._id)
console.log(that.cart[v].goods_price)


方法很多,如果用for in,就是上面这样拿。

还可以用for、forEach、for of、map、...



评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付