This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const routes = [ | |
{ | |
path: "/about/create", | |
component: About | |
}, | |
{ | |
path: "/about/:id", | |
component: About | |
} | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="app"> | |
<router-link to="/parent">Go to the nested part</router-link> | |
<router-view></router-view> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const FirstChild = { | |
template: "<div>Hi I'm the first child</div>" | |
}; | |
const SecondChild = { | |
template: "<div>Hi I'm the second child</div>" | |
}; | |
const ParentComponent = { | |
template: `<div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="app"> | |
<router-link :to="{name: 'white'}">Go to the same named route</router-link> | |
<router-view></router-view> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const NamedRoute = { | |
template: "<div>Named route content</div>" | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const routes = [ | |
{ | |
path: "/black", | |
name: "white", | |
component: NamedRoute | |
} | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const routes = [ | |
{ | |
path: "/contact/:id", | |
component: Contact, | |
props: true | |
} | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Contact = { | |
props: ["id"], | |
template: "<div>Contact view</div>", | |
mounted: function() { | |
console.log("Welcome to the Contact view"); | |
const userId = this.id; | |
if (userId) { | |
console.log("You are viewing the user", userId); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const routes = [ | |
{ | |
path: "/about/:id", | |
component: About | |
} | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const About = { | |
template: "<div>About view</div>", | |
mounted: function() { | |
console.log("Welcome to the About view"); | |
const userId = this.$route.params.id; | |
if (userId) { | |
console.log("You are viewing the user:", userId); | |
} | |
}, |
NewerOlder