Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    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.



    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




    Instructor: 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.

    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.

    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.

    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.

    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.