Up until a few years ago, direct DOM manipulation was the standard in frontend development, with jQuery leading the way. All that started changing with the popularization of modern JavaScript libraries and frameworks, mainly Angular and React. And then, in February of 2014, Vue came out with its initial release.
With large IT companies backing both Angular and React, it was not clear how Vue would carve out its position. Initially developed by a single developer, Evan You, in four short years—and without corporate backing—Vue went from being the fun little project of a single developer to an unlikely rival to the big boys, with over 300 contributors. It's not a one-man show anymore.
Today, Vue is used by NASA, GitLab, Alibaba, Grammarly, WizzAir, EuroNews, Xiaomi, Adobe, Behance, Nintendo, Chess.com, and many others.
Conclusion? Vue is here to stay. And while there might be an on-going discussion about whether it's better to learn Elm, or React, or Angular, or Ember, or something entirely different, this discussion is largely irrelevant. Each library and framework has something to offer, and in the end, it's simply a matter of trying it out and seeing whether it works for you.
We developers need to embrace the necessity to surf the technology wave and accept that learning new frameworks and paradigms is simply a part of our careers. Therefore, the question is not whether we should learn Vue, or any other battle-tested and proven tech out there.
Vue has already achieved its ranking, and it's playing in the same league with the big boys. The only question is, How do I learn it efficiently? and this book is an attempt to answer that question.
This book is aimed at beginner-to-intermediate frontend web developers with no prior experience with Vue or other VDOM JavaScript libraries. It would be beneficial for readers to have some JavaScript and CSS knowledge. It is aimed at quickly bringing the reader up to speed regarding just how exactly Vue is set up and how its moving parts work together. It is meant to give you an overview of almost the entire Vue landscape, succinctly, and with lots of examples.
The goal of this book is simple – to quickly and efficiently introduce you to Vue and to ease you into the framework without a major investment of time and energy. The intended result is for you to have a huge return on investment – to gain enough practical knowledge of the framework that by the time you've read the book, which should not take long, you are confident to tackle some more advanced Vue projects and concepts.
Chapter 1, Introducing Vue, discusses what Vue is and gets started with mustache templates. We look at problems that Vue solves and reasons to use Vue.
Chapter 2, Basic Concepts of Vue 2, discusses reactivity, computed properties, and methods. We also introduce components, templates, props, watchers, and life cycle hooks.
Chapter 3, Working with Vue-CLI, Components, Props, and Slots, shows how to install vue-cli and how to set up code editors to work with Vue more effectively. We inspect the structure of a vue-cli-based project, look at how to add basic functionality to a child component, and look at passing data from children to parent components.
Chapter 4, Filters and Mixins, describes how to use filters. We look at syntax, use cases, and some examples. We also examine working with mixins.
Chapter 5, Making Your Own Directives and Plugins, looks at ways to extend Vue by making our own, custom directives. We also build our own plugin from scratch and learn how to publish it via npm.
Chapter 6, Transitions and Animations, takes the reader step by step from comparing CSS transitions with CSS animation to understanding the differences between them and how to start integrating them with Vue. We then discuss a myriad of ways to organize transitions and animations in Vue—with transition and transition-group components, with transition hooks as CSS classes, with named transition hooks, and with JavaScript transition hooks.
Chapter 7, Using Vuex, shows the reader, from the ground up, just exactly what state is and why it's important. It also explains the reasons to have the store – the centralized state – and how its internals work. We also tinker with some code examples of controlling our apps from this centralized store.
Chapter 8, Using Nuxt.js and Vue-Router, describes how SPAs work, what issues they have, and how these issues can be overcome with server-side rendering and code splitting. We then see how to build a very simple Nuxt.js app with a few pages, and some added transitions.
This book will work for you best if you can do the following:
- Code basic HTML, CSS, and JavaScript
- Understand in general how the internet and browsers work
- Have some experience working with code editors and console programs
- Are willing to download examples (or fork them from CodePen)
The JavaScript code in this book is mostly written in ES5, but as the book progresses, sometimes ES6 has sneaked in. The reason for using ES5 is because it is not assumed that the reader understands ES6 syntax. Likewise, it is not assumed that readers have not used it before—hence, a compromise was made: not to focus on the features of ES6, but not to completely disregard them either. It is the author's humble opinion that this approach will shift the focus to where it matters: understanding Vue.
You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.
You can download the code files by following these steps:
- Log in or register at www.packt.com.
- Select the
SUPPORT
tab. - Click on
Code Downloads & Errata
. - Enter the name of the book in the
Search
box and follow the onscreen instructions.
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/Vue.js-Quick-Start-Guide. In case there's an update to the code, it will be updated on the existing GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://www.packtpub.com/sites/default/files/downloads/9781789344103_ColorImages.pdf.
There are a number of text conventions used throughout this book.
CodeInText
: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Mount the downloaded WebStorm-10*.dmg
disk image file as another disk in your system."
A block of code is set as follows:
... data: { // the model goes here } ...
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
div,.thetemplate {
font-size: 30px;
padding: 20px;
color: limegreen;
font-family: Arial;
Any command-line input or output is written as follows:
cd quickstart-vue
Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Select System info
from the Administration
panel."
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected]
.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packt.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.
Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected]
with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!
For more information about Packt, please visit packt.com.