今天遇到个bug,分享一下js报错:Uncaught TypeError: i.push is not a function

// 配置自动转换 cookie 的 JSON 格式数据         $.cookie.json = true         // 读取保存在 cookie 中的购物车数组         const cart = $.cookie('cart') || []   let cart1 = []
        console.log(cart);         $.each(cart, function (i) {                          $.ajax({                 url: `http://www.xiongmaoyouxuan.com/api/detail?id=${cart[i].id}&normal=1&sa=`,                 success(resData) {                     console.log(resData)                     cart1 = cart1.push(JSON.stringify(resData))                     console.log(cart1)                 }             })
        }) js报错:Uncaught TypeError: i.push is not a function   let 比 function 优先级高   // 配置自动转换 cookie 的 JSON 格式数据         $.cookie.json = true         // 读取保存在 cookie 中的购物车数组         const cart = $.cookie('cart') || []   
        console.log(cart);         $.each(cart, function (i) {             let cart1 = []  //改             $.ajax({                 url: `http://www.xiongmaoyouxuan.com/api/detail?id=${cart[i].id}&normal=1&sa=`,                 success(resData) {                     console.log(resData)                     cart1 = cart1.push(JSON.stringify(resData))                     console.log(cart1)                 }             })
        })
上一篇:解决 TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host m


下一篇:【VUE】 TypeError: this.getOptions is not a function at Object.lessLoader