vue el-table 動態表頭

 

 
    res: {
        code: 200,
        data: {
            Header: ["姓名", "年齡", "性別出生年月"],
            Content: [
                ["張三", "20", "男"],
                ["李四", "20", "男"],
                ["王五", "20", "男"],
                ["趙六", "20", "男"],
                ["田七", "20", "男"],
                ["錢八", "20", "男"],
                ["孫九", "20", "男"],
                ["周十", "20", "男"],
            ]
        }
    }
     
<el-table :data="res.data.Content">
        <el-table-column v-for="(item, index) in res.data.Header" :key="item" :label="item" show-overflow-tooltip align="center" :min-width="item.length > 7 ? '190' : '110'">
              <template slot-scope="scope">
                   <span>{{res.data.Content.length > 0 ? res.data.Content[scope.$index][index]:''}}</span>
              </template>
        </el-table-column>
</el-table>

單純只是記錄一下

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章