Reader small image

You're reading from  Vue.js 2.x by Example

Product typeBook
Published inDec 2017
Reading LevelBeginner
PublisherPackt
ISBN-139781788293464
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Mike Street
Mike Street
author image
Mike Street

Mike Street (aka mikestreety) is a frontend developer from Brighton, UK. Specializing in Gulp, SCSS, HTML, and Vue, he has been developing websites professionally since 2010. After making his first Vue app as an experimental side project, he's been hooked ever since. When not developing on the web, Mike likes to explore the Sussex countryside on his bike, start a new side-project without finishing the last, or heading to the cinema.
Read more about Mike Street

Right arrow

Making file and folder components

With our data types separated out, we can create individual components to compartmentalize the data and methods. Create a folder component that accepts a single property, allowing the folder object variable to be passed through. As the template is so small, there is no need for a view or <script> block-based template; instead, we can pass it in as a string on the component:

      Vue.component('folder', {
template: '<li><strong>{{ f.name }}</strong>
</li>',
props: {
f: Object
},
});

To make our code smaller and less repetitive, the prop is called f. This tidies up the view and lets the component name determine the display type without repeating the word folder several times.

Update the view to use the folder component, and pass in the entry variable...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Vue.js 2.x by Example
Published in: Dec 2017Publisher: PacktISBN-13: 9781788293464

Author (1)

author image
Mike Street

Mike Street (aka mikestreety) is a frontend developer from Brighton, UK. Specializing in Gulp, SCSS, HTML, and Vue, he has been developing websites professionally since 2010. After making his first Vue app as an experimental side project, he's been hooked ever since. When not developing on the web, Mike likes to explore the Sussex countryside on his bike, start a new side-project without finishing the last, or heading to the cinema.
Read more about Mike Street