I am attempting to pass a props via the vue router using a router link that appears like this
<router-link :to="{ name: 'product-details', params: { productId: 123 } }" class="product-sbb d-block">
Below are my routes
{
path: '/product/details/:productId',
name: 'product-details',
props: true,
components: {
navbar: Navbar,
default: ProductDetail,
footer: Footer
},
},
I have set the props to true and included the params in the path /:productId. I also referred to the example provided in this link https://codesandbox.io/s/o41j762pnz
Despite following the example, I am facing an issue where the props always appear as undefined when trying to use them in my component. Here is my component
import ProductDetail from '../components/parts/ProductDetailGallery.vue';
export default {
props: {
productId: Number
},
data() {
},
created() {
console.log(this.productId)
}
}
While the example runs perfectly without any problems, mine does not. How can I resolve this issue?
Thank you