Complete Vue.js 2 Web Development_ Practical guide to building end-to-end web development solutions with Vue.js 2

(singke) #1

Using Vue-Router Dynamic Routes to Load Data Chapter 9


basket</button></td>
</tr>
</table>
</div>

<div v-html="product.body"></div>

</div>
<page-not-found v-if="productNotFound"></page-not-found>
</div>`,

components: {
PageNotFound
},
data() {
return {
productNotFound: false,
image: false
}
},

computed: {
product() {
let product;

if(Object.keys(this.$store.state.products).length) {

product = this.$store.state.products[this.$route.params.slug];
this.image = (product.images.length)? product.images[0] : false;

if(!product) {
this.productNotFound = true;
}
}

console.log(product);
return product;
}
},

methods: {
updateImage(img) {
this.image = img;
},

variantTitle(variation) {
let variants = variation.variant,
output = [];
Free download pdf