Reputation: 385
I have /your
route with a /your/profile
nested route. When I go to /your
, the text "Index" is rendered. When going the nested route (/your/profile
), it doesn't show anything. Both the Index & Profile components are not even mounted.
I'm expecting to see the text "Index" & "Profile" (below it), as well as the alert text. But None are showing. I have followed the instruction as documented from the official source. Any idea what's causing the issue?
import Your from "../views/your/Index.vue";
import Profile from "../views/your/Profile.vue";
const routes = [
{
path: "/your",
name: "Your",
component: Your,
children: [
{
path: "/profile",
component: Profile
}
]
}
];
<template>
<div>
<v-container>
<p>Index</p>
<router-view></router-view>
</v-container>
</div>
</template>
<script>
export default {
name: "Your",
mounted() {
alert("Index Mounted");
}
};
</script>
<template>
<div>
<p>Profile</p>
</div>
</template>
<script>
export default {
name: "Profile",
mounted() {
alert("Profile Mounted");
}
};
</script>
Upvotes: 0
Views: 775
Reputation: 338
Remove the / from children
Because this will be treated as root path
Look at vue docs
Upvotes: 1