Book Image

Learning Vue.js 2

By : Olga Filipova
Book Image

Learning Vue.js 2

By: Olga Filipova

Overview of this book

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.
Table of Contents (18 chapters)
Learning Vue.js 2
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Dedication
Preface

Preface

This book is about Vue.js. We will start our journey trying to understand what Vue.js is, how it compares to other frameworks, and what it allows us to do. We will learn different aspects of Vue.js while building small funny applications on top of it and applying these aspects in practice. In the end, we will look back to see what've we learned and have a look into the future to see what we can still learn and do. So, you will learn the following:

  • What is Vue.js and how it works
  • Reactivity and data binding with Vue.js
  • Reusable components with Vue.js
  • Plugins for Vue.js
  • Testing and deploying applications written in Vue.js

All the examples in this book are built on top of the recently released Vue 2.0 version. The book also contains references to the previous version regarding deprecated or changed aspects of the framework.

I am sure you will enjoy the process of building applications using Vue.js with this book.

What this book covers

Chapter 1, Going Shopping with Vue.js, contains an introduction to Vue.js, to the terminology used through the book, and first basic examples.

Chapter 2, Fundamentals – Installing and Using, explains the behind the scenes of Vue.js, provides theoretical insights into the architectural pattern, touches nearly all the main Vue.js concepts, and bootstraps the applications that will be developed through the book.

Chapter 3, Components – Understanding and Using , goes deep into components and explains how to rewrite applications using a simple component system and single-file components.

Chapter 4, Reactivity – Binding Data to Your Application , contains a detailed explanations of the usage of data binding mechanisms in Vue.js.

Chapter 5, Vuex – Managing State in Your Application , contains detailed introduction to Vuex, a state management system for Vue.js, and explains how to use it in your application in order to achieve a nice, maintainable architecture.

Chapter 6, Plugins – Building Your House with Your Own Bricks , shows how to use plugins in Vue applications and explains how to use an existing plugin in an application and explains how to build our own plugin and then use it.

Chapter 7, Testing – Time to Test What We Have Done So Far, contains an introduction to the testing techniques that can be used in Vue applications to bring them to the needed level of quality. We tackle it by showing how to write unit tests and how to develop end-to-end tests for the applications in the book.

Chapter 8, Deploying – Time to Go Live!, shows how to bring your Vue application to the world, guaranteeing its quality with continuous integration tools. It explains how to connect a GitHub repository to the Travis continuous integration system and to the Heroku cloud deployment platform.

Chapter 9, What Is Next, wraps up everything that has been done so far and leaves the reader with the follow up steps.

AppendixSolutions to Exercises, provides solutions to the exercises for first three chapters.

What you need for this book

The requirements for this book are the following:

  • Computer with an Internet connection
  • Text editor/IDE
  • Node.js

Who this book is for

This book is for web developers or for people who want to become web developers. Whether you have just started to work with web technologies or you are already a guru of frameworks and languages in the vast ocean of web technologies, this book might show you something new in the world of reactive web applications. If you are a Vue developer and have used Vue 1.0, this book might be a useful guide for you to migrate to Vue 2.0, since all the examples of the book are based on Vue 2.0. Even if you are already using Vue 2.0, this book might be a nice exercise of building an application from scratch, applying all Vue and software engineering concepts and taking it to the deployment stage.

At least some technical background is required. If you can already write code in JavaScript, it is a huge plus.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Your plugin must provide an install method."

A block of code is set as follows:

export default {
  components: {
    ShoppingListComponent,
    ShoppingListTitleComponent
  },
  computed: mapGetters({
    shoppinglists: 'getLists'
  })
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

export default {
  components: {
    ShoppingListComponent,
    ShoppingListTitleComponent
  },
  computed: mapGetters({
    shoppinglists: 'getLists'
  }),
  methods: mapActions(['populateShoppingLists']),
  store,
  mounted () {
    this.populateShoppingLists()
  }
}

Any command-line input or output is written as follows:

cd shopping-list
npm install vue-resource --save-dev

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Check the Developer mode checkbox."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.
  2. Hover the mouse pointer on the SUPPORT tab at the top.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box.
  5. Select the book for which you're looking to download the code files.
  6. Choose from the drop-down menu where you purchased this book from.
  7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Learning-Vue.js-2. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.