I need to change the data in a Vue Component depending on the route. For example, when the page Aircraft is loaded I want the data to contain the Aircraft images. If the page Animals is then loaded then I want the data to contain the Animals images.
The website can be seen here: https://test.joebaileyphotography.com/Portfolio
Vue.component('subitem', {
props: ['photo'],
template: `
<a :href="photo.img">
<img :src="photo.img" width="100%" height="auto">
</a>
`
});
const subitem = {
data() {
return {
photos: [
{img: 'Images/Portfolio/Aircraft/image1.jpg'},
{img: 'Images/Portfolio/Aircraft/image1.jpg'},
{img: 'Images/Portfolio/Aircraft/image1.jpg'}
],
}
},
template: `
<div>
<breadcrumbs></breadcrumbs>
<info></info>
<div class="portfolio" id="portfolio" data-featherlight-gallery data-featherlight-filter="a:not(.all)">
<subitem
v-for="subitem in photos"
:key="subitem.photo"
v-bind:photo="subitem">
</subitem>
</div>
</div>
`
};
const router = new VueRouter({
mode: 'history',
routes: [
{ path: '/Portfolio/:id', component: subitem },
{ path: '/Portfolio', component: item }
]
});
$route.params.id
and show the photos based on thatconst subitem = { data() {