Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Vue.js 3 By Example
Vue.js 3 By Example

Vue.js 3 By Example: Blueprints to learn Vue web development, full-stack development, and cross-platform development quickly

By John Au-Yeung
₱1,796.99 ₱1,256.99
Book Apr 2021 320 pages 1st Edition
eBook
₱1,796.99 ₱1,256.99
Print
₱2,245.99
Subscription
Free Trial
eBook
₱1,796.99 ₱1,256.99
Print
₱2,245.99
Subscription
Free Trial

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now
Table of content icon View table of contents Preview book icon Preview Book

Vue.js 3 By Example

Chapter 1: Creating Your First Application in Vue 3

Vue 3 is the latest version of the popular Vue.js framework. It is focused on improving developer experience and speed. It is a component-based framework that lets us create modular, testable apps with ease. It includes concepts that are common to other frameworks such as props, transitions, event handling, templates, directives, data binding, and more. The main goal of this chapter is to get you started with developing your first Vue app. This chapter is focused on how to create components.

In this chapter, we will look at how to use Vue 3 to create simple apps from scratch. We will start by building the most basic apps and then move on to building more complex solutions in the next few chapters.

The major topics we will cover are as follows:

  • Understanding Vue as a framework
  • Setting up the Vue project
  • Vue 3 core features – components and built-in directives
  • Debugging with Vue.js Devtools

Technical requirements

Understanding Vue as a framework

As we mentioned in the introduction, there are concepts in Vue that are available from other frameworks. Directives manipulate the Document Object Model (DOM) just like in Angular.js and Angular. Templates render data like we do with Angular. It also has its own special syntax for data binding and adding directives.

Angular and React both have props that pass data between components. We can also loop through array and object entries to display items from lists. Also, like Angular, we can add plugins to a Vue project to extend its functionality.

Concepts that are exclusive to Vue.js include computed properties, which are component properties that are derived from other properties. Also, Vue components have watchers that let us watch for reactive data changes. Reactive data is data that is watched by Vue.js and actions are done automatically when reactive data changes.

As reactive data changes, other parts of a component and other components...

Setting up the Vue project with the Vue CLI and script tag

There are several ways to create Vue projects or to add script tags to our existing frontends. For prototyping or learning purposes, we can add the latest version of Vue 3 by adding the following code:

<script src="https://unpkg.com/vue@next"></script>

This will always include the latest version of Vue in our app. If we use it in production, we should include the version number to avoid unexpected changes from newer versions breaking our app. The version number can replace the next word if we want to specify the version.

We can also install Vue by installing it as a package. To do that, we can run the following command:

npm install vue@next

This will install the latest version of Vue in our JavaScript project.

If we created a Vue project from scratch with an older version of the Vue CLI, then we can use the CLI to generate all the files and install all the packages for us. This is the...

Vue 3 core features – components and built-in directives

Now that we have created a basic Vue app with a Vue instance, we can look more closely at how to make it do more. Vue 3 is a component-based framework. Therefore, components are the core building blocks that are used to build full production - quality Vue 3 apps. Components are parts that can be combined to form a full app and are reusable. Vue 3 components have several parts, which include the template, the component option object, and the styles. The styles are the CSS styles that we apply to the rendered elements. The template is what is rendered on the browser's screen. It contains HTML code combined with JavaScript expressions to form the content that's rendered in the browser.

Templates get their data from the corresponding component option object. Also, the component templates can have directives that control how content is rendered and how to bind data from the template to a reactive property.

Components...

Debugging with Vue.js Devtools

Right now, there is no easy way to debug our app. All we can do is add console.log statements to our code to look at the values. With Vue.js Devtools, we can have more visibility in our app. Vue.js Devtools is a Chrome or Firefox extension that we can use to debug our Vue.js applications. It can be used on projects that are created with Vite or created from scratch by including the script tag for Vue 3. We can install the extension by searching for the Vue.js Devtools extension in the respective browser's app store.

Important:

The URL to install the Chrome version of Vue.js Devtools is at https://chrome.google.com/webstore/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd.

The Firefox version of the add-on is at https://addons.mozilla.org/en-CA/firefox/addon/vue-js-devtools/?utm_source=addons.mozilla.org&utm_medium=referral&utm_content=search.

Once we've installed it, we should see the Vue tab in the browser's development...

Summary

In this chapter, we learned that Vue 3 is a component-based framework, and we looked at the different parts of the component. One important part we covered was reactive properties. They are properties of the component that we can change to update all the parts of the app that reference the reactive property. These properties can be watched manually, and any value changes are also picked up automatically by Vue 3 so that any parts of the app that reference the reactive property are updated automatically. Components are composed in a way that they can be reused whenever possible.

We then moved on to understand the role of a template in every component. Templates are also a part of every component. They must all render something onto the screen. Templates can have HTML elements, other components, and directives that modify how the elements and components in the template are rendered. Templates can have JavaScript expressions in them so that we can do things such as react to...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Download complete source code for all Vue.js projects built throughout the book
  • Discover steps to build production-ready Vue.js apps across web, mobile, and desktop
  • Build a compelling portfolio of web apps, including shopping cart system, booking app, slider puzzle game, real-time chat app, and more

Description

With its huge ecosystem and wide adoption, Vue is one of the leading frameworks thanks to its ease of use when developing applications. However, it can get challenging for aspiring Vue.js developers to make sense of the ecosystem and build meaningful applications. This book will help you understand how you can leverage Vue effectively to develop impressive apps quickly using its latest version – Vue 3.0. The book takes an example-based approach to help you get to grips with the basics of Vue 3 and create a simple application by exploring features such as components and directives. You'll then enhance your app building skills by learning how to test the app with Jest and Vue Test Utils. As you advance, you'll understand how to write non-web apps with Vue 3, create cross-platform desktop apps with the Electron plugin, and build a multi-purpose mobile app with Vue and Ionic. You'll also be able to develop web apps with Vue 3 that interact well with GraphQL APIs. Finally, you'll build a chat app that performs real-time communication using Vue 3 and Laravel. By the end of this Vue.js book, you'll have developed the skills you need to build real-world apps using Vue 3 by working through a range of projects.

What you will learn

Get to grips with Vue architecture, components, props, directives, mixins, and other advanced features Understand the Vue 3 template system and use directives Use third-party libraries such as Vue Router for routing and Vuex for state management Create GraphQL APIs to power your Vue 3 web apps Build cross-platform Vue 3 apps with Electron and Ionic Make your Vue 3 apps more captivating with PrimeVue Build real-time communication apps with Vue 3 as the frontend and Laravel

Product Details

Country selected

Publication date : Apr 26, 2021
Length 320 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781838826345
Category :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Apr 26, 2021
Length 320 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781838826345
Category :

Table of Contents

10 Chapters
Preface Chevron down icon Chevron up icon
1. Chapter 1: Creating Your First Application in Vue 3 Chevron down icon Chevron up icon
2. Chapter 2: Building a Vue 3 Progressive Web App Chevron down icon Chevron up icon
3. Chapter 3: Building a Slider Puzzle Game with Tests Chevron down icon Chevron up icon
4. Chapter 4: Building a Photo Management Desktop App Chevron down icon Chevron up icon
5. Chapter 5: Building a Multipurpose Calculator Mobile App with Ionic Chevron down icon Chevron up icon
6. Chapter 6: Building a Vacation Booking App with the PrimeVue UI Framework Chevron down icon Chevron up icon
7. Chapter 7: Creating a Shopping Cart System with GraphQL Chevron down icon Chevron up icon
8. Chapter 8: Building a Chat App with Vue 3, Laravel, and Socket.IO Chevron down icon Chevron up icon
9. Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%
Top Reviews
No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.