rutas ajustadas

This commit is contained in:
2020-08-22 02:25:43 -05:00
parent 6863cf7306
commit 1f7f93861a
8 changed files with 108 additions and 80 deletions
+22 -26
View File
@@ -62,15 +62,16 @@
style="width: 12rem;"
v-bind:key="libro.id"
v-for="libro in Libros"
@click="descripcion(libro.id)"
>
<router-link :to="{ path: 'home' }" class="textt">
<div class="textt">
<img :src="libro.img" class="card-img-top rounded" alt="libro" />
<div class="card-body cd textt">
<p class="card-text textt">
{{ libro.title }}
</p>
</div>
</router-link>
</div>
</div>
</div>
</div>
@@ -100,30 +101,20 @@ export default {
desc: ``,
boton2: "",
categoria: "",
Libros: [
{
id: 0,
title: "",
img: ""
},
{
id: 1,
title: "",
img: ""
},
{
id: 1,
title: "",
img: ""
}
]
Libros: []
};
},
methods: {
async descripcion(idLibro) {
localStorage.clear();
window.localStorage.setItem("idLibro", idLibro);
location.reload();
}
},
async created() {
let path = `${config.api}`;
try {
//this.idLibro = window.localStorage.getItem("idLibro");
this.idLibro = 1;
this.idLibro = window.localStorage.getItem("idLibro");
let detalle = await axios.get(
`${config.api}/libroDetalle?idLibro=${this.idLibro}`
);
@@ -144,11 +135,12 @@ export default {
} catch (error) {
console.log(error);
}
this.idLibro = 1;
try {
let config = {
// example url
url: `http://localhost:3000/libroImagen?idLibro=${this.idLibro}`,
url: `${path}/libroImagen?idLibro=${this.idLibro}`,
method: "GET",
responseType: "blob"
};
@@ -169,10 +161,9 @@ export default {
similares = similares.data.data;
console.log(`${similares}`);
for (let i = 0; i < similares.length; i++) {
this.Libros[i].title = similares[i].titulo;
let config = {
// example url
url: `http://localhost:3000/libroImagen?idLibro=${i + 2}`,
url: `${path}/libroImagen?idLibro=${i + 2}`,
method: "GET",
responseType: "blob"
};
@@ -180,7 +171,12 @@ export default {
let reader = new FileReader();
reader.readAsDataURL(response.data);
reader.onload = () => {
this.Libros[i].img = reader.result;
this.Libros.push({
id: similares[i].idLibro,
title: similares[i].titulo,
img: reader.result
});
//this.Libros[i].img = reader.result;
};
});
}