Vue.js Quick Start Guide: Learn how to build amazing and complex reactive web applications easily using Vue.js
()
About this ebook
Learn and explore all important features of Vue.js through a number of simple examples.
Key Features
- Uses latest features such as Vue-cli 3, Vuex, and Nuxt
- Practical examples to understand Vue 2 quickly
- Step-by-step approach to reinforce concepts covered
Book Description
Vue.js is the latest trending frontend framework. Simplicity, reactivity, and ?exibility are some of the key benefits that Vue offers to developers. This book will help you learn everything you need to know to build stunning reactive web apps with Vue.js 2 quickly and easily.
This book will take you through the Vue 2 framework. You will start by learning the different Vue installation options: CDN, NPM, and Vue CLI. Then we will look at the core concepts of Vue: templates and components – ways to modularize Vue code. You will learn how to utilize directives, which are Vue-specific HTML attributes with additional features. Also, you will see how Vue uses a streamlined approach to development, with reusable methods, computed properties, and watchers, and how it controls state with the help of its data option.
You will learn about the concepts of reactive programming in Vue, and how to understand communication between parent and child components. We will take a look at props and slots, working with CSS, filters, and mixins. We will also look at ways to add transitions and animations to Vue apps. Then you will extend Vue by building custom directives and your own plugins.
Finally, you will learn about Vuex – a Vue plugin that allows us to centralize state, and also introduce Nuxt, which is a framework that builds on top of Vue and solves some issues of single-page applications. After learning about these components, you will be ready to build your own reactive web apps with Vue.js 2.
What you will learn
- Develop apps with Vue.js
- Reuse components using slots
- Use filters, mixins, and global mixins in Vue
- Build custom directives in Vue
- Work with CSS animations
- Work with templates, directives, methods, data, computed properties, and watchers
- Use Nuxt and Vue-Router
- Build and deploy an SSR Vue app
Who this book is for
This book is for people who want to learn and experience developing with Vue.js. Familiarity with HTML, CSS, and JavaScript will help you get the most from this book.
Read more from Ajdin Imsirovic
Bootstrap 4 Cookbook Rating: 0 out of 5 stars0 ratingsElm Web Development: An introductory guide to building functional web apps using Elm Rating: 0 out of 5 stars0 ratingsVue CLI 3 Quick Start Guide: Build and maintain Vue.js applications quickly with the standard CLI Rating: 0 out of 5 stars0 ratings
Related to Vue.js Quick Start Guide
Related ebooks
Building Forms with Vue.js: Patterns for building and scaling complex forms with great UX Rating: 0 out of 5 stars0 ratingsVue.js 2 Design Patterns and Best Practices: Build enterprise-ready, modular Vue.js applications with Vuex and Nuxt Rating: 0 out of 5 stars0 ratingsWebpack 5 Up and Running: A quick and practical introduction to the JavaScript application bundler Rating: 0 out of 5 stars0 ratingsMERN Quick Start Guide: Build web applications with MongoDB, Express.js, React, and Node Rating: 0 out of 5 stars0 ratingsVuex Quick Start Guide: Centralized State Management for your Vue.js applications Rating: 0 out of 5 stars0 ratingsModern JavaScript Web Development Cookbook: Easy solutions to common and everyday JavaScript development problems Rating: 0 out of 5 stars0 ratingsGetting Started with Web Components: Build modular and reusable components using HTML, CSS and JavaScript Rating: 0 out of 5 stars0 ratingsHands-On Parallel Programming with C# 8 and .NET Core 3: Build solid enterprise software using task parallelism and multithreading Rating: 0 out of 5 stars0 ratingsASP.NET Core MVC 2.0 Cookbook: Effective ways to build modern, interactive web applications with ASP.NET Core MVC 2.0 Rating: 0 out of 5 stars0 ratingsLearning Angular for .NET Developers Rating: 0 out of 5 stars0 ratingsBlazor Quick Start Guide: Build web applications using Blazor, EF Core, and SQL Server Rating: 0 out of 5 stars0 ratingsLearn WebAssembly: Build web applications with native performance using Wasm and C/C++ Rating: 0 out of 5 stars0 ratingsSpring 5.0 By Example: Grasp the fundamentals of Spring 5.0 to build modern, robust, and scalable Java applications Rating: 0 out of 5 stars0 ratingsASP.NET Core 2 and Vue.js: Full Stack Web Development with Vue, Vuex, and ASP.NET Core 2.0 Rating: 0 out of 5 stars0 ratingsASP.NET Core 3 and React: Hands-On full stack web development using ASP.NET Core, React, and TypeScript 3 Rating: 0 out of 5 stars0 ratingsASP.NET Core and Vue.js: Build real-world, scalable, full-stack applications using Vue.js 3, TypeScript, .NET 5, and Azure Rating: 0 out of 5 stars0 ratingsMastering Windows Presentation Foundation: Build responsive UIs for desktop applications with WPF, 2nd Edition Rating: 0 out of 5 stars0 ratingsHands-On Design Patterns with React Native: Proven techniques and patterns for efficient native mobile development with JavaScript Rating: 0 out of 5 stars0 ratingsASP.NET Core 5 and Angular: Full-stack web development with .NET 5 and Angular 11 Rating: 0 out of 5 stars0 ratingsJavaScript Cloud Native Development Cookbook: Deliver serverless cloud-native solutions on AWS, Azure, and GCP Rating: 0 out of 5 stars0 ratingsAngular 6 by Example: Get up and running with Angular by building modern real-world web apps, 3rd Edition Rating: 0 out of 5 stars0 ratingsNext.js Quick Start Guide: Server-side rendering done right Rating: 0 out of 5 stars0 ratingsAWS Networking Cookbook Rating: 0 out of 5 stars0 ratings
Programming For You
HTML in 30 Pages Rating: 5 out of 5 stars5/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5Learn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5Python Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5Excel 101: A Beginner's & Intermediate's Guide for Mastering the Quintessence of Microsoft Excel (2010-2019 & 365) in no time! Rating: 0 out of 5 stars0 ratingsSQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5C# Programming from Zero to Proficiency (Beginner): C# from Zero to Proficiency, #2 Rating: 0 out of 5 stars0 ratingsPython Data Structures and Algorithms Rating: 5 out of 5 stars5/5Python QuickStart Guide: The Simplified Beginner's Guide to Python Programming Using Hands-On Projects and Real-World Applications Rating: 0 out of 5 stars0 ratingsSQL: For Beginners: Your Guide To Easily Learn SQL Programming in 7 Days Rating: 5 out of 5 stars5/5Linux Command-Line Tips & Tricks Rating: 0 out of 5 stars0 ratingsLearn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS Rating: 5 out of 5 stars5/5HTML & CSS: Learn the Fundaments in 7 Days Rating: 4 out of 5 stars4/5PYTHON: Practical Python Programming For Beginners & Experts With Hands-on Project Rating: 5 out of 5 stars5/5Coding All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsLearning JavaScript Data Structures and Algorithms Rating: 5 out of 5 stars5/5Deep Learning with Python Rating: 5 out of 5 stars5/5The Most Concise Step-By-Step Guide To ChatGPT Ever Rating: 3 out of 5 stars3/5
Reviews for Vue.js Quick Start Guide
0 ratings0 reviews
Book preview
Vue.js Quick Start Guide - Ajdin Imsirovic
Vue.js Quick Start Guide
Learn how to build amazing and complex reactive web applications easily using Vue.js
Ajdin Imsirovic
BIRMINGHAM - MUMBAI
Vue.js Quick Start Guide
Copyright © 2018 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author(s), nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Commissioning Editor: Kunal Chaudari
Acquisition Editor: Siddharth Mandal
Content Development Editor: Kirk Dsouza
Technical Editor: Sushmeeta Jena
Copy Editor: Safis Editing
Project Coordinator: Hardik Bhinde
Proofreader: Safis Editing
Indexer: Rekha Nair
Graphics: Alishon Mendonsa
Production Coordinator: Nilesh Mohite
First published: October 2018
Production reference: 1241018
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78934-410-3
www.packtpub.com
mapt.io
Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Mapt is fully searchable
Copy and paste, print, and bookmark content
Packt.com
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at customercare@packtpub.com for more details.
At www.packt.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
Contributors
About the author
Ajdin Imsirovic has been working with frontend technologies, as well as web and print design, for almost two decades. He is an accomplished video course creator and the author of Bootstrap 4 Cookbook and Elm Web Development, both by Packt Publishing. In his third book, Vue.js Quick Start Guide, he eases in the newcomers to the Vue ecosystem in a clear and concise manner.
I would like to thank my parents for raising me to understand and appreciate the value of hard work and the value of not giving up.
About the reviewers
Sufyan bin Uzayr is a writer, teacher, and developer with more than 10 years' experience in the industry. He is an open source enthusiast and specializes in a wide variety of technologies. He holds four masters' degrees and has authored multiple books.
Sufyan is an avid writer. He regularly writes about topics related to coding, tech, politics, and sports. He is a regular columnist for various publications and magazines.
Sufyan is the CEO of Parakozm, a software development company catering to a global clientele. He is also the CTO at Samurai Servers, a web server management company focusing mainly on enterprise-scale audiences.
In his spare time, Sufyan teaches coding and English to young students.
There are many people that I wish to thank:
Faisal Fareed and Sadaf Fareed, my siblings, for helping with things back home. The team at Packt, especially Hardik Bhinde, and others, for giving me the opportunity to review this book. The authors, and the Vue.js community, for all their hardwork and effort.
Andrea Koutifaris has a passion for programming which he likes to say is in his DNA. At the age of thirteen, he began using his father’s laptop to write his own programs. After graduating high school he enrolled, without a second thought, at the University of Florence, Faculty of Computer Engineering. After being a Java developer for some years, Andrea gradually moved to front-end development which is his passion till date. Having spent too much time fixing problems in messed up code, he is obsessed with good programming and test-driven development which, in his opinion, is the only way to write production quality code. Andrea has authored the book, Vuex Quick Start Guide, published recently by Packt.
Packt is searching for authors like you
If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Table of Contents
Title Page
Copyright and Credits
Vue.js Quick Start Guide
Packt Upsell
Why subscribe?
Packt.com
Contributors
About the author
About the reviewers
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Download the color images
Conventions used
Get in touch
Reviews
Introducing Vue
What is Vue?
The quickest way to start using Vue2
Mustache template example
Using Vue's data option as a function
What problems does Vue solve?
Vue, a jQuery successor
A learning tool for beginners
A versatile and progressive framework
A tool for animations and transitions
Features similar to other modern frontend frameworks and libraries
Why use Vue?
Declarative code
Feels like a right fit for a variety of projects
Easy-to-understand syntax
Directives
Modifiers
Vue methods
Computed properties and watchers
Summary
Basic Concepts of Vue 2
Data-driven views in Vue
What is reactivity?
How does Vue achieve this?
Computed properties and methods
What exactly are these dependencies?
Understanding components, templates, and props
Adding props and data for better components
Adding content to our components with the help of the data object
Other ways of building component templates in Vue
Building a simple web page out of components
Adding simple components to a Vue instance
Creating a more complex page out of components in Vue
Improving our Vue-based layouts with v-for
Watchers in Vue
Lifecycle hooks
What is a component's lifecycle?
How do we use lifecycle hooks?
Summary
Working with Vue-CLI, Components, Props, and Slots
Vue component hierarchy, and global and local components
Using Vue-CLI
Installing Git bash
Installing nvm
Why use nvm?
Installing and updating Vue-cli
Initializing a new project with Vue-cli
Setting up code editors to use with Vue
Working with Vue.js in Sublime Text 3
Dowloading Sublime Text 3
Install Package Manager
Working with Vue.js in VS Code
Installing VS Code and extensions
The structure of our Vue-cli-based project
Adding basic functionality to a child component
Adding props to our HelloAgain.vue
Passing data from children to parent components
Introduction to slots
Summary
Filters and Mixins
Using filters
An example of a filter that rounds up student grades
Using filters as a replacement for conditional directives
Chaining filters in Vue
Working with mixins
Building a simple app with repetitive functionality in different components
Staying DRY with mixins
Refactoring our viewportSize mixin
Summary
Making Your Own Directives and Plugins
Making our own directives
Understanding custom directives
Building a simple custom directive
Using local directives
Passing values to custom directives
Working with Vue plugins
Creating the simplest possible Vue plugin
Creating a plugin with options defined
Publishing a Vue plugin
Adding a simple plugin
Installing our NPM plugin in a Vue project using Vue CLI 3
Additional plugins to learn from
Summary
Transitions and Animations
Transitions and animations in CSS
How CSS transitions work
How CSS animations work
Differences between transitions and animations in CSS
Rules for CSS transitions
Rules for CSS animations
The transition element in Vue
Setting up the enter transition
Setting up the leave transition
Naming transition components
CSS animations with transition component
Custom transition classes
Combining transition modes, duration, keys, and v-if
Binding CSS styles in Vue
Animating a button on click with dynamic CSS classes
Working with transition groups
JavaScript animation hooks
Summary
Using Vuex
What is state?
State management, data stores, and one-way data flows
The Vuex state management pattern
The store
Getters in the Vuex store
Vuex store mutations
Actions in Vuex store
Hot reloading
Building a fruit counter app with Vuex
Using the Vue DevTools plugin to track our Vuex state
Improving our fruit counter app
Summary
Using Nuxt.js and Vue-Router
Single-page applications and server-side rendering
Installing Nuxt.js and previewing the default project
Installing Nuxt.js with the vue init command
Debugging an eslint error
Installing with create-nuxt-app
Editing the index.vue file
Nuxt pages as routes
Adding navigation to Nuxt apps via the components folder
Adding content to our Nuxt app's pages
Adding page transitions to our Nuxt.js app
Summary
Other Books You May Enjoy
Leave a review - let other readers know what you think
Preface
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.
Who this book is for
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