【问题标题】:Vue and Element ComponentVue 和元素组件
【发布时间】:2017-12-27 17:36:26
【问题描述】:

我有一个复杂的对象,为简洁起见,对象的结构如下:

{
     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

【问题讨论】:

    标签: vue.js vuejs2 element element-io


    【解决方案1】:

    我知道为什么循环不起作用,因为CollectionSample 中。你的数据结构是一个Sample 数组,它包含一个对象。

    因此,您可以将代码修复为:

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

    【讨论】:

      猜你喜欢
      • 2023-03-23
      • 2018-03-16
      • 1970-01-01
      • 2018-04-28
      • 1970-01-01
      • 2018-07-16
      • 2019-10-28
      • 2021-01-19
      • 2019-01-02
      相关资源
      最近更新 更多