2017-09-19 02:41:00 +02:00
|
|
|
<template>
|
2017-09-19 04:28:26 +02:00
|
|
|
<div>
|
|
|
|
<template v-if="isLoading">
|
|
|
|
<p>Loading…</p>
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
<h2>{{ this.product.product_name }}</h2>
|
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<th>Barcode</th>
|
|
|
|
<td>{{ $route.params.barcode }}</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</template>
|
|
|
|
</div>
|
2017-09-19 02:41:00 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
2017-09-19 04:28:26 +02:00
|
|
|
created() {
|
|
|
|
this.fetchData();
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
// Fetch again when the component is updated
|
|
|
|
$route: 'fetchData',
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
product() {
|
|
|
|
return this.$store.getters.product;
|
|
|
|
},
|
|
|
|
isLoading() {
|
|
|
|
return this.$store.getters.isLoading;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
fetchData() {
|
|
|
|
this.$store.dispatch('getProduct', { EAN: this.$route.params.barcode });
|
|
|
|
},
|
|
|
|
},
|
2017-09-19 02:41:00 +02:00
|
|
|
};
|
|
|
|
</script>
|