橘猫敲代码 2023-12-15 16:25 采纳率: 64.1%
浏览 6
已结题

table内有数组,如何赋值


   <el-table border :data="dispatchList">
            <el-table-column label="承运人" prop="zoneName" :render-header="addRedStar">
              <template slot-scope="scope">
                <el-select v-model="scope.row.carrierId" clearable filterable
                  @change="carrierSelect(scope.row.carrierId,scope.$index)" style="width:100%">
                  <el-option v-for="item in carrierList" :key="item.carrierId" :value="item.carrierId"
                    :label="item.carrierName"></el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="基础分区" prop="zoneName" :render-header="addRedStar">
              <template slot-scope="scope">
                <el-select v-model="scope.row.dispatchZoneAndTypeList[scope.$index].zoneId" clearable filterable
                  style="width:100%">
                  <el-option v-for="item in BasePartition" :key="item.id" :value="item.id" :label="item.dispatchZoneName">
                  </el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="DAS" prop="zoneName">
              <template slot-scope="scope">
                {{scope.row.dispatchZoneAndTypeList}}
                <el-select v-model="scope.row.dispatchZoneAndTypeList[scope.$index].zoneId" clearable filterable
                  style="width:100%">
                  <el-option v-for="item in DasPartition" :key="item.id" :value="item.id"
                    :label="item.dispatchZoneName">
                  </el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="EAS" prop="zoneName">
              <template slot-scope="scope">
                <el-select v-model="scope.row.dispatchZoneAndTypeList[scope.$index].zoneId" clearable filterable
                  style="width:100%">
                  <el-option v-for="item in EasPartition" :key="item.id" :value="item.id"
                    :label="item.dispatchZoneName">
                  </el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="RAS" prop="zoneName">
              <template slot-scope="scope">
                <el-select v-model="scope.row.dispatchZoneAndTypeList[scope.$index].zoneId" clearable filterable
                  style="width:100%">
                  <el-option v-for="item in RasPartition" :key="item.id" :value="item.id"
                    :label="item.dispatchZoneName">
                  </el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="操作" align="center" width="86">
              <template slot-scope="scope">
                <i class="iconfont icon-shanchuicon" @click="del_box(scope.$index)"></i>
              </template>
            </el-table-column>
          </el-table>

   dispatchList : [{
            carrierId: '',
            carrierName: '',
            dispatchZoneAndTypeList: [{
                dispatchZoneTypeId: '313',
                zoneId: '',
                zone: '',
              },
              {
                dispatchZoneTypeId: '314',
                zoneId: '',
                zone: '',
              },
              {
                dispatchZoneTypeId: '315',
                zoneId: '',
                zone: '',
              },
              {
                dispatchZoneTypeId: '316',
                zoneId: '',
                zone: '',
              }
            ]
          }],

这种数组里边有数组的格式,怎么给下拉框赋值,dispatchZoneAndTypeList传红框中每一个下拉框

img

  • 写回答

2条回答 默认 最新

  • 二九筒 2023-12-15 16:32
    关注

    用 v-for 循环该数组,然后把select标签放在v-for里面,然后取值赋值就行了

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 8月8日
  • 创建了问题 12月15日