Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Full-Stack Vue.js 2 and Laravel 5

You're reading from   Full-Stack Vue.js 2 and Laravel 5 Bring the frontend and backend together with Vue, Vuex, and Laravel

Arrow left icon
Product type Paperback
Published in Dec 2017
Publisher Packt
ISBN-13 9781788299589
Length 376 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Anthony Gore Anthony Gore
Author Profile Icon Anthony Gore
Anthony Gore
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Hello Vue – An Introduction to Vue.js FREE CHAPTER 2. Prototyping Vuebnb, Your First Vue.js Project 3. Setting Up a Laravel Development Environment 4. Building a Web Service with Laravel 5. Integrating Laravel and Vue.js with Webpack 6. Composing Widgets with Vue.js Components 7. Building a Multi-Page App with Vue Router 8. Managing Your Application State with Vuex 9. Adding a User Login and API Authentication with Passport 10. Deploying a Full-Stack App to the Cloud

Virtual DOM


Let's change tack now and discuss how Vue renders components. Take a look at this example:

Vue.component('my-component', {
  template: '<div id="my-component">My component</div>'
});

In order for Vue to be able to render this component to the page, it will first transform the template string into a JavaScript object using an internal template compiler library:

Figure 6.14. How the template compiler turns a template string into an object

Once the template has been compiled, any state or directives can easily be applied. For example, if the template includes a v-for, a simple for-loop can be used to multiply the nodes and interpolate the correct variables.

After that, Vue can interface with the DOM API to synchronize the page with the state of the component.

Render functions

Rather than supplying a string template for your component, you can instead supply a render function. Without understanding the syntax, you can probably tell from the following example that the render...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime