// 错误写法
that.couponList = couponListTemp.filter(item=>{item.categoryId &&(item.categoryId === that.goods.categoryId}))
// 正确写法
that.couponList = couponListTemp.filter(item=>item.categoryId &&(item.categoryId === that.goods.categoryId))
// 正确写法
that.couponList = couponListTemp.filter(item=>{return item.categoryId &&(item.categoryId === that.goods.categoryId}))
JS数组过滤技巧
本文介绍JavaScript中使用filter方法的正确姿势,对比了错误与正确的代码写法,帮助开发者避免常见陷阱,提高代码质量和效率。
733

被折叠的 条评论
为什么被折叠?



