Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

dynamic route vue

// Add dynamic segment to route path, enable props to give component access to :id parameter
{
    path: '/event/:id', // dynamic segment
    name: 'EventDetails',
    props: true, // allows dynamic segment to be passed as props to component
    component: EventDetails
},

// bind router link to route name and pass id as parameter:
<router-link :to="{ name: 'EventDetails', params: { id: event.id } }">
  
// use id as prop in EventDetails component:
export default {
  props: ['id'],
  // ...
Source by www.vuemastery.com #
 
PREVIOUS NEXT
Tagged: #dynamic #route #vue
ADD COMMENT
Topic
Name
6+9 =