我制作了很多桌子,所以我制作了一个制作桌子的组件。每张桌子只有 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>目标是能够打印对象内的属性值(特别是通过将对象本身和要打印的属性作为单独的道具传递给组件)。我可以吗?
添加回答
举报
0/150
提交
取消
