modularize items

This commit is contained in:
Timo Hocker 2019-10-21 11:07:16 +02:00
parent 850091188f
commit 2db228bdb1
2 changed files with 26 additions and 7 deletions

View File

@ -8,12 +8,7 @@
:key="key" :key="key"
>{{value}}</th> >{{value}}</th>
</tr> </tr>
<tr v-for="(row,rowKey) in json.data" :key="rowKey"> <Item v-for="(row,rowKey) in json.data" :key=rowKey :data=row :hidden=json.hidden></Item>
<td
v-for="(value,key) in row.filter((val,ind)=>!json.hidden.includes(ind))"
:key="key"
>{{value}}</td>
</tr>
</table> </table>
</div> </div>
<br /> <br />
@ -27,6 +22,8 @@
</template> </template>
<script> <script>
import {Item} from "./Item";
export default { export default {
name: "App", name: "App",
data() { data() {
@ -39,7 +36,8 @@ export default {
fetch("?json") fetch("?json")
.then(res => res.json()) .then(res => res.json())
.then(json => (self.json = json)); .then(json => (self.json = json));
} },
components: [Item]
}; };
</script> </script>

21
web/src/Item.vue Normal file
View File

@ -0,0 +1,21 @@
<template>
<tr id="item">
<td
v-for="(value,key) in data.filter((val,ind)=>!hidden.includes(ind))"
:key="key"
>{{value}}</td>
</tr>
</template>
<script>
export default {
name: "Item",
properties: {
data: Object,
hidden: Array
}
};
</script>
<style scoped>
</style>