vue3 + ts 从数据中拿到单个属性,并存为字符串和数组
1 let cart_idsAll = ""; 2 //从对象中遍历拿到指定属性 3 selectArrey.value.forEach(function (item) { 4 //存为字符串 5 (cart_idsAll as any) += (item as any).goods_id + ","; 6 }); 7 //将字符串的最后一","删除,并根据","转为数组 8 (cart_idsAll as any) = cart_idsAll.substring(0,cart_idsAll.length-1).split(","); 9 if (cart_idsAll != "") { 10 console.log("cart_idsAll", cart_idsAll); 11 } else { 12 ElMessage({ 13 message: "没有选中任何订单!", 14 type: "warning", 15 });