Book Image

Vue.js Quick Start Guide

By : Ajdin Imsirovic
Book Image

Vue.js Quick Start Guide

By: Ajdin Imsirovic

Overview of this book

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.
Table of Contents (15 chapters)
Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
Index

Adding page transitions to our Nuxt.js app


As we learned in Chapter 6Transitions and Animations, Vue comes with a wide array of ways to add interactivity, transitions, and animations to our apps. To make this process faster, we will use animations from Animate.css, with some slight modifications.

In Nuxt, we can use page transition hooks just like we already learned. We'll simply replace the v letter inside the .v-* transition hooks with .page-*. All the functionality, and the way everything works, will stay the same.

Let's begin by opening the pages/index.vue file and adding this code at the top of its style tag:

.page-enter-active, .page-leave-active {
  transition: opacity 1s;
}
.page-enter, .page-leave-active {
  opacity: 0;
}

Next, we'll open the contact.vue file and add this code at the top of its style tag:

.page-enter-active {
    animation: zoomIn .5s;
} 
@keyframes zoomIn {
from {
    opacity: 0;
    transform: scale3d(0.4, 0.4, 0.4);
}

50% {
    opacity: 1;
}
}

.zoomIn {
animation...