zoukankan      html  css  js  c++  java
  • 二级联动:map,for循环一级数据,调用接口获取对象数据依次放到数组里(解决由于后端java是多线程,接收到的数据放入(push)数组中有可能会顺序不对) (循环发送请求,返回结果没有按请求顺序排序)promise

    解决方法1:遍历一级数据时先push一个新的对象,调用接口获取到数据之后splice方法通过index的值判断放入到数组的对应下标下
    this.tableData一级数据:
     this.relationMaterialNameList二级数据:
    this.tableData.map((item,index)=>{
                                this.relationMaterialNameList.push({})
                                // 编辑页面项目下拉框数据
                                this.getSpecificationList(item.reimbursementType, index)
         })
     
     // 项目下拉数据
                getSpecificationList(code, index) {
                    // 项目下拉数据
                    this.$axios({
                        url: `/chenfan_sample/sampleDevReim/relationMaterial?reimbursementType=${code}`,
                        method: 'get',
                    }).then((res) => {
                        if (res.code === 200) {
                            this.relationMaterialNameList.splice(index, 1, res.obj)
                        }
                    })
                },
    解决方法2:promise all 是按顺序返回的
  • 相关阅读:
    easy Html5 Jquery Mobile之ToolBars(Header and Footer)
    Windows Phone7 性能
    easy Html5 Jquery Mobile之Buttons
    开篇,从这里开始。
    SkyDrive APIs——用户登录和APP授权(2)
    Windows Phone的强大语音控制,让你的Phone大秀一把
    SkyDrive APIs之——操作文件和文件夹(3)
    Mango in my mind 之 Live Tile
    SkyDrive APIs——搭建环境(1)
    windows10安装redis
  • 原文地址:https://www.cnblogs.com/wssdx/p/12427327.html
Copyright © 2011-2022 走看看