自定義<el-table-column> 數據格式:數組對象,且每條對象中有一個數組對象


自定義el-table-column 后台的數據格式:數組對象,且每條對象中有一個數組對象

一 數據格式:

 

 每條對象中goodsCategoryList的數據是一種類型。

 

二 代碼

<el-table-column v-for="(item, index) in tableData[0].goodsCategoryList" :key="index" :label="item.attrName">
                <!-- 數據的遍歷  scope.row就代表數據的每一個對象-->
                <template slot-scope="scope">
                  <span>{{scope.row.goodsCategoryList[index].attrValue}}</span>
                </template>
              </el-table-column>

v-for="(item, index) in tableData[0].goodsCategoryList"
遍歷tableData[0].goodsCategoryList的目的:1 獲取item,用於給表頭賦值。
2 獲取index,作為下表,用於scope.row.goodsCategoryList[index].attrValue用

本人親測:

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM