前端实现批量添加功能

313 阅读1分钟

一、临时使用,循环遍历访问同一个接口

二、批量添加快捷应用功能分析

1、通过点击事件,event.target.checked 判断是否被选中

2、 选中则将选项id,存储在数组中,否则过滤选项id

3、发送请求时,对数组进行遍历,封装成请求体格式

三、关键代码:

   let spreadList = []
    this.checkedData.forEach((item, index) => {
          spreadList.push(axios(...));
        });
        Promise.all(spreadList).then(() => {
         // 执行...
        });