Join egghead, unlock knowledge.

Want more egghead? It's 45% off for a limited time only!

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock All Content for 45% Off

Already subscribed? Sign In

Save 45% for a limited time.

Get access to all courses and lessons on egghead today.

Autoplay

    Get Started with Vue Components

    Rory SmithRory Smith

    Components are one of the most powerful features of Vue. Let's take a look at how to write our first components and make use of them in a parent component.

    vueVue.js
    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Transcript

    Transcript

    Instructor: 00:00 Let's start by making a components folder. Inside the folder we'll have item description, item image, and item title. These will separate components that we can put together in our app. Now we can write the components that we're going to use.

    00:15 We're making a page that's going to show some information and the picture of my cat, Opel. Let's write an item title, an item description, and an item image. Let's start writing the parent Vue template which is going to make use of those components.

    00:32 We'll start by importing each Vue components. Then, we need to declare each component individually within the component's object. We can do this using the ESX object showhand.

    00:46 Let's write our template. It's going to be a div with the idea of app whose children are each of the three components. The template is referring to the components that we specify down here. The only difference is that we're using kebab-case up here in our template whereas down here, it's capitalized.

    01:04 Let's run a dev instance of our app and see if it works. There we have the item image, the item title, and the item description, and we can inspect all of these in our Vue dev tools as well.

    Discuss

    Discuss