⚠️ This lesson is retired and might contain outdated information.

Use Vue Router-Link to Navigate within Components

Laurie Barth
InstructorLaurie Barth
Share this video with your friends

Social Share Links

Send Tweet
Published 5 years ago
Updated 3 months ago

Vue-router comes with a built-in router-link component that can be used for navigation links between pages.

Instructor: [00:02] Vue has a tag built in called router-link, which can help with all of your router template needs.

[00:12] We'll start with the router-link and put an internal <h3> tag so that it will expand to meet the space of the text. Now we want to add a to path, which is where this router-link will take us. We'll send it to /egghead. If we refresh our page and click on the link, we'll go to our Egghead page.

[00:46] If we want to change the styling of the router-link, there are many API options. tag="button" is one of them. Now our link appears as a button.

[01:00] If we want to navigate to blog and handle parameters in our navigation, we need to navigate using an object. We use the name that we've set for the blog route record, blog, and send params as another object with key id and a value of 1, 2, 3, 4. If we click on the router-link, we see that we've successfully navigated to blog 1, 2, 3, 4.

egghead
egghead
~ 26 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today