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         });

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM