Vue and Element Component

vue.js vuejs2 element element-io

230 观看

1回复

9200 作者的声誉

I have a complex object, for brevity the object is structured in this manner:

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

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

The data table renders the model data fine. But, when trying to access the collection, the table doesn't output the data.

<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>

Does the data being binded to the table ignore the loop? I'm able to access during the binding as a prop, the data is being sent over, but when the loop is added, the data doesn't output.

Element-io Vue

作者: Greg 的来源 发布者: 2017 年 12 月 27 日

回应 1


1

26 作者的声誉

决定

I know why the loop is not work, because Collection is in the Sample. Your data structure is a Sample array, it contains an object.

data structs

So, you can fix the code to this:

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

作者: 陳煜璿 发布者: 2017 年 12 月 28 日
32x32