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
Learning Vue.js 2
Learning Vue.js 2

Learning Vue.js 2: Learn how to build amazing reactive web applications easily with Vue.js

Arrow left icon
Profile Icon Olga Filipova
Arrow right icon
Free Trial
Full star icon Full star icon Full star icon Full star icon Half star icon 4.4 (10 Ratings)
Paperback Dec 2016 334 pages 1st Edition
eBook
zł59.99 zł158.99
Paperback
zł197.99
Subscription
Free Trial
Arrow left icon
Profile Icon Olga Filipova
Arrow right icon
Free Trial
Full star icon Full star icon Full star icon Full star icon Half star icon 4.4 (10 Ratings)
Paperback Dec 2016 334 pages 1st Edition
eBook
zł59.99 zł158.99
Paperback
zł197.99
Subscription
Free Trial
eBook
zł59.99 zł158.99
Paperback
zł197.99
Subscription
Free Trial

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Learning Vue.js 2

Chapter 2. Fundamentals – Installing and Using

In the previous chapter, we gained some familiarity with Vue.js. We were able to use it in two different applications that we created from scratch. We learned how to integrate Vue.js into an already existing project. We were able to see Vue's reactive data binding in action.

Now, you are probably asking yourself: how does it work? What does it do to achieve this behavior of fast UI changes when the data model is changed? Probably, you decided to use Vue.js in your project and are now wondering whether it follows some architectural pattern or paradigm so that you should adopt it in your project. In this chapter, we will explore the key concepts of the Vue.js framework to understand all its behind the scenes features. Also in this chapter, we will analyze all the possible ways of installing Vue.js. We will also create a skeleton for our applications, which we will develop and enhance through the next chapters. We will also...

MVVM architectural pattern

Do you remember how we were creating the Vue instance in the first chapter? We were instantiating it calling new Vue({...}). You also remember that in the options, we were passing the element on the page where this Vue instance should be bound and the data object that contained the properties we wanted to bind to our View. The data object is our Model and the DOM element where the Vue instance is bound is our View:

MVVM architectural pattern

Classic View-Model representation where the Vue instance binds one to another

In the meantime, our Vue instance is something that helps to bind our Model to the View and vice versa. Our application thus follows Model-View-ViewModel (MVVM) pattern, where the Vue instance is a ViewModel:

MVVM architectural pattern

The simplified diagram of the Model-View-ViewModel pattern

Our Model contains data and some business logic, and our View is responsible for its representation. ViewModel handles data binding, ensuring that the data changed in the Model is immediately affecting the...

DefineProperty, getters, and setters

So, what happens with the data once passed to the Vue instance? What are these transformations that Vue applies to it so that it becomes so automatically bound to the View layer?

Let's analyze what would we do if we had, let's say, a string, and every time it changes we would like to apply some transformations to some DOM element. How would we apply the string-changing listener function? To what would we attach it? There is no such thing as var stringVar='hello';stringVar.onChange(doSomething) .

So we would probably wrap the string's value setting and getting in some sort of function that would do something, for example, updating the DOM each time the string was updated. How would you implement it? While you're thinking about it, I'll prepare a quick demo of something interesting.

Open the developer tools on your shopping list application. Let's code a little bit. Create an obj variable and another text variable...

Comparing with other frameworks

When you try a new tool, you want to know how it compares with other tools or frameworks. You can find a deep analysis in this regard on the official page of Vue.js: http://vuejs.org/guide/comparison.html . I will just point to some topics that I find important regarding the mostly used frameworks.

React

React and Vue are really similar. They both use virtual DOM, have reusable components, and are about reactive data. It is worth mentioning, however, that Vue only uses virtual DOM starting from its second major version. Prior to Vue 2.0, it used real DOM. The Vue 2.0 release not only became more performant than Vue 1.0 but it also became more performant than React ( http://vuejs.org/guide/comparison.html#Performance-Profiles ).

The most significant difference is probably the way you create your components in both frameworks. You might already know that in React, everything is JavaScript. Developing everything, even templates, in JavaScript, can actually be...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Learn how to propagate DOM changes across the website without writing extensive jQuery callbacks code.
  • Learn how to achieve reactivity and easily compose views with Vue.js and understand what it does behind the scenes.
  • Explore the core features of Vue.js with small examples, learn how to build dynamic content into preexisting web applications, and build Vue.js applications from scratch.

Description

Vue.js is one of the latest new frameworks to have piqued the interest of web developers due to its reactivity, reusable components, and ease of use. This book shows developers how to leverage its features to build high-performing, reactive web interfaces with Vue.js. From the initial structuring to full deployment, this book provides step-by-step guidance to developing an interactive web interface from scratch with Vue.js. You will start by building a simple application in Vue.js which will let you observe its features in action. Delving into more complex concepts, you will learn about reactive data binding, reusable components, plugins, filters, and state management with Vuex. This book will also teach you how to bring reactivity to an existing static application using Vue.js. By the time you finish this book you will have built, tested, and deployed a complete reactive application in Vue.js from scratch.

Who is this book for?

This book is perfect for novice web developer seeking to learn new technologies or frameworks and also for webdev gurus eager to enrich their experience. Whatever your level of expertise, this book is a great introduction to the wonderful world of reactive web apps.

What you will learn

  • Build a fully functioning reactive web application in Vue.js from scratch.
  • The importance of the MVVM architecture and how Vue.js compares with other frameworks such as Angular.js and React.js.
  • How to bring reactivity to an existing static application using Vue.js.
  • How to use plugins to enrich your applications.
  • How to develop customized plugins to meet your needs.
  • How to use Vuex to manage global application's state.

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Dec 13, 2016
Length: 334 pages
Edition : 1st
Language : English
ISBN-13 : 9781786469946
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Dec 13, 2016
Length: 334 pages
Edition : 1st
Language : English
ISBN-13 : 9781786469946
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just zł20 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just zł20 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 593.97
Vue.js 2 and Bootstrap 4 Web Development
zł197.99
Learning Vue.js 2
zł197.99
Vue.js 2 Cookbook
zł197.99
Total 593.97 Stars icon

Table of Contents

10 Chapters
1. Going Shopping with Vue.js Chevron down icon Chevron up icon
2. Fundamentals – Installing and Using Chevron down icon Chevron up icon
3. Components – Understanding and Using Chevron down icon Chevron up icon
4. Reactivity – Binding Data to Your Application Chevron down icon Chevron up icon
5. Vuex – Managing State in Your Application Chevron down icon Chevron up icon
6. Plugins – Building Your House with Your Own Bricks Chevron down icon Chevron up icon
7. Testing – Time to Test What We Have Done So Far! Chevron down icon Chevron up icon
8. Deploying – Time to Go Live! Chevron down icon Chevron up icon
9. What Is Next? Chevron down icon Chevron up icon
A. Solutions to Exercises Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.4
(10 Ratings)
5 star 60%
4 star 30%
3 star 0%
2 star 10%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Herbal Apr 22, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is a great book.. I advice you to buy this book.. It's very clear and the most important thing is It's not needed component base application because this book gives you the idea.. and naturally the necessary skills to begin developing immediately.
Amazon Verified review Amazon
WiltDurkey Feb 17, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I quite liked it. Bear in mind when reading this review where I am coming from:- somewhat of a JS newbie, but have been working with it for a while using Jquery to do front-end stuff on a Django app, all with require.js and pre-es6 stuff (i.e. no Node.js or equivalent).- my frontend code was a tangled mess and really I needed to put in something cleaner. Vue fit the bill, because I could read and follow its introductory code right away, unlike React/Angular/Ember. Simple _and_ powerful is always a winning combination in my book. And it didn't seem to _require_ an SPA approach.- but... Vue, especially 2.0, is newer and has less books or online materials, so I needed something to hold my hands going from basic Hello World type examples to something more complex. All the same, I wanted basic stuff because SPA type examples wouldn't apply and I was more interested in the concepts.Pheew! Sorry for the long preamble, but it'll give you an idea of what motivates my review.First, it is quite well structured and easy to follow. You have the obligatory test applications (2 or 3 of them) and they start out using basic Vue features and then, as you go through the chapters and new Vue concepts are introduced, you see them reused, elegantly, in the apps. The apps, IMHO, strike the right balance between not being totally trivial and providing you some insight on what a real Vue-based app might look like. Vs dumping you off at the deep end with some complex code that forces you to think about the app's structure rather than what Vue is doing.Second, Vue itself mostly doesn't care that much about being used as a simple CDN-sourced library or whether it comes from a more sophisticated Node-based system. So I was following the book writing my JS as usual. But as you start looking at reusing Vue Components, then yes, Node or similar is the more natural (and less complex!) way to go. At some point, the book goes into setting up a basic Node+Webpack and points you where to download its own sample configuration. As I had node + npm already installed, I gave it a try and, lo and behold, the sample app ran perfectly. So I kind of stumbled into modern JS best practices following it along. Hey, this is about 5 pages, so no great amount of unnecessary content if you already use Webpack. But a brilliant leg up if you don't and would like to.While it builds on basic concepts, it is not dumbed down - for example there is a detailed explanation of how Vue reactivity works under the covers, starting with how you would achieve it by wrapping attributes in getters and setters.The development concepts conclude with an intro to Vuex, and how to use it to federate data and state among components. This is also important, because, as good as Vue is, it doesn't have a builtin system (events aside) to wire components together and components are compartmentalized by design. That's what Vuex is for. So you can consider Vue+Vuex as the need-to-have for real apps. Again, the concepts are well explained and easy to follow.There is some further material about testing as well. So quite a comprehensive coverage of what it covers. (Should have included 'slots' though).Conclusion: I think that, if you were coming in as an experienced Angular/React/etc... SPA-type dev, then not seeing Vue-Router/Resource and the focus on just the basics might hold you back a bit. You would certainly benefit from the way this book complements the, pretty darn good, official Vue documentation. But you might also be able to figure these things out on your own, without this book. Either way some of the more sophisticated stuff is out of scope here. So it's really a choice between are you a self-researcher or I-prefer-a-book type of guy.To be honest, while I got it at a discount, the full price is somewhat steep - but it's supply and demand stuff - few Vue books, premium price for now (c.f. the dude with the 40page/25$ book) . If you are finding your way into modern JS frontend libraries, Vue's simplicity is appealing and this book is very helpful in gently getting you up to speed.p.s. For some reason the Kindle Paperwhite version uses the smallest font ever. Whenever reading it, I am forced to switch to the largest or next-to-largest size setting, at which point it works well. But then I have to switch it back to the smaller sizes I usually use for other books. No such problem on the iPad Kindle app.
Amazon Verified review Amazon
Amazon Customer Aug 07, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Love it, the author does a good job of explaining things in a digestible way.
Amazon Verified review Amazon
Sherwin John C. Tragura Mar 12, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I was looking for some help in understanding the MVC components of VUE application and this one laid out everything i need. Great book!
Amazon Verified review Amazon
amiralles Jul 08, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is awesome! The chapters are packed with code, advise, examples, tips, tricks, and a bit of humor here and there. I highly recommend this book to anyone trying to learn Vue.js.From a basic hello world to real world working app (two, actually), the author teaches you how to build, refactor, test and deploy your Vue.js apps.The code is really well written and easy to follow. I really enjoyed this book. Five starts!
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.