I am using client side routing and have the route name be the object's name
. I am linking to the Edit.vue
component but if I want to render the age
in that Edit
component, how do I get that passed in? I know I have name
accessible in the router params but I want the other fields in that object too, such as age
.
App.vue
<div v-for="item in items">
<router-link :to="`/edit/${item.name}`"> Edit ${item.name} </router-link>
</div>
data() {
return {
items: [ {name: "Carl", age: 23}, { name: "James", age: 43}]
}
}
then in my router config, I have:
const routes = [
{
path: "/",
name: "Home",
component: Home,
},
{
path: "/edit/:name",
name: "Edit",
component: () =>
import(/* webpackChunkName: "edit" */ "../views/Edit.vue"),
},
];