问题是关于VueJS框架-元素: http://element.eleme.io
我有一些从数组中获取数据的表(el table):
<el-table :data="someData"> <el-table-column prop="id" label="â"></el-table-column> <el-table-column prop="is_active" label="Active"></el-table-column> </el-table>
axios从DB获取JSON,数组如下所示:
[ { "id":1, "is_active":0 }, { "id":2, "is_active":1 },{ "id":3, "is_active":1 } ]
有人知道如何说元素表只显示属性为“is\u active”的行,即eq 0或1(或其他条件)?
你可以使用 computed property 筛选阵列,例如:
computed: { filteredList() { if (this.someData) { return this.someData.filter(data => data && data.is_active); } return []; }, },
然后将此筛选列表绑定到组件:
<el-table :data="filteredList">