From the course: Vue.js 2 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Creating reusable components

Creating reusable components

From the course: Vue.js 2 Essential Training

Start my 1-month free trial

Creating reusable components

- Once your code starts getting really long you may want to divide your project into little pieces. And what's really nice about this is that if you're going to be using the same types of things in multiple projects you can create a separate component that does something and then share that component with different projects. So what I'm going to do is write a component that's going to output this price, and it will also allow us to use the euro notation instead of the dollar sign and perhaps even do a conversion. So I'm going to get started just by creating the most basic component that you can, and to do that, I'm going to come up here and use my Vue object to create just a regular component, let's go ahead and hide this right here 'cause it's going to be blinking for quite a while, and we use the component key word, and then we're going to give the component a name. So you can use something like this, you can say like, my dash price, or you can use camel case if you want to, but…

Contents