I have a getter where all products are stored there, and when I want to get only one product dynamically depending on this.$route.params.id
it doesn't return any value
this code works correctly when I navigate to a certain product, but when I refresh the page I lose everything
computed: {
...mapGetters(["getAllProducts"]),
product() {
return this.getAllProducts.filter(item => {
return item.id === this.$route.params.id;
});
}
}
But if I supplied filter()
with static value in instead of this.$route.params.id
like below it works
product() {
return this.getAllProducts.filter(item => {
return item.id === 1;
});
}
I really don't know what is the problem, despite of in another component in my project I did some filters on some computed properties and it worked
update: the routes config
{
path: "/product/:id",
name: "product-page",
component: ProductPage,
props: true
}