为了账号安全,请及时绑定邮箱和手机立即绑定

V-for 显示对象的特定属性

V-for 显示对象的特定属性

慕盖茨4494581 2021-06-28 14:11:47
我制作了很多桌子,所以我制作了一个制作桌子的组件。每张桌子只有 3 种不同的东西:对象(对象数组。每个对象 1 行)特定于该表的标题我特别想显示的对象属性我的组件:Vue.component('table-component', {  props: {    headers: Array,    data_for_rows: Object,    data_properties_to_display: Array,  },  template: `  <div>    <table class="table-hover">      <thead>          <tr>              <th v-for='item in headers'>{{item}}</th>          </tr>      </thead>      <tbody>          <tr v-for='object in data_for_rows'>              <td v-for='property in data_properties_to_display'>{{object.property}}</td>          </tr>      </tbody>  </table></div>`});HTML 本身:                    <table-component :headers="['Party','Members','Votes With Party %']" data_for_rows="glance_data"                        :data_properties_to_display="['partyName','memberCount','percentage']">                    </table-component>目标是能够打印对象内的属性值(特别是通过将对象本身和要打印的属性作为单独的道具传递给组件)。我可以吗?
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 286 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号