2017-12-27 511 views
0

我有一個複雜的對象,爲了簡潔的目的被構造以這種方式:Vue公司和子元件構件

{ 
    Sample: [{ 
     Model: { 
      Id: "1" 
     }, 

     Collection: [{ 
      Id: "1" 
     }]  
    }] 
} 

數據表使得該模型數據細。但是,當試圖訪問集合時,表格不會輸出數據。

<template> 
    <el-table :data="Sample" highlight-current-row :row-class-name="tableRow" stripe :default-sort="{ prop: 'Sample.Id, order: 'descending'}"> 
      <el-table-column type="expand"> 
       <el-row :gutter="20" v-for="property in Collection"> 
        <el-col :span="24"><div>Id: {{ property.Id }}</div></el-col> 
       </el-row> 
      </el-table-column> 
      <el-table-column prop="Model.Id" label="Id" width="300"></el-table-column> 
    </el-table> 
</template> 

綁定到表的數據是否忽略循環?我能夠在綁定期間作爲道具訪問數據,但是當添加循環時,數據不會輸出。

Element-io Vue

回答

0

我知道爲什麼循環不行的,因爲CollectionSample。你的數據結構是一個Sample數組,它包含一個對象。

data structs

所以,你可以修改代碼這樣:

v-for="(property,index) in Sample[0].Collection"