blob: 3c35b35510fd274d27362401a3f48c2556b1387e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
<template>
<div class="mt-5 d-flex justify-content-center">
<div class="card col-md-8">
<div class="row g-0">
<div class="col-md-6">
<img :src="productImg" class="img-fluid rounded-start">
</div>
<div class="col-md-6">
<div class="card-body">
<h3 class="card-title" v-text="productName"></h3>
<b><i>Price: ${{ productPrice }}</i></b><br/>
<p class="card-text" v-text="productDescription"></p>
<div class="btn btn-dark" @click="buy">Add to cart</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import axios from 'axios';
export default {
name: 'Product',
async mounted() {
await axios.get(`${process.env.VUE_APP_ROOT_API}/products/${this.$route.params.id}`)
.then(response => {
this.productName = response.data.name;
this.productDescription = response.data.description;
this.productImg = `${process.env.VUE_APP_ROOT_API}/${response.data.imagePath}`;
this.productPrice = response.data.price;
})
.catch(error => console.error(error));
},
data() {
return {
productName: String,
productDescription: String,
productImg: String,
productPrice: Number
}
},
methods: {
buy() {
}
}
}
</script>
|