1
I would like to know how to change the content of a component based on a parameter that is in the url of my site.
I’m developing a portfolio and in it I created a file called Works.See.
I don’t know if I did it right, but in this same file I created an array with the content I want to present.
If it is in /stamp/1 it shows the content it finds with this id in the array and so on.
In Jobs.I have the following code:
<template>
<div>
( Conteúdo de acordo com o ID encontrado na url )
</div>
</template>
<script>
export default {
data() {
return {
estampas: [
{
id: '1',
name: 'Estampa 1',
content: [
{ img: 'https://via.placeholder.com/500x300&text=Estampa', caption: 'Legenda 1 estampa 1' },
{ img: 'https://via.placeholder.com/500x300&text=Estampa', caption: 'Legenda 2 estampa 1' },
{ img: 'https://via.placeholder.com/500x300&text=Estampa', caption: 'Legenda 3 estampa 1' }
]
},
{
id: '2',
name: 'Estampa 2',
content: [
{ img: 'https://via.placeholder.com/500x300&text=Estampa', caption: 'Legenda 1 estampa 2' },
{ img: 'https://via.placeholder.com/500x300&text=Estampa', caption: 'Legenda 2 estampa 2' }
]
},
]
}
}
}
</script>
Good morning man, the resolution to your problem is Vuerouter Dynamic: https://router.vuejs.org/guide/essentials/dynamic-matching.html
– Joan Marcos
Good morning, thanks for the reply! I had already taken a look at this part of the documentation. I even forgot to mention but on my route I already have a path: '/stamp/:id'. I’m a little lost on how to exchange content in Works.Vue based on the url id.
– user3681