Learn the core concepts of Vue.js, the modern JavaScript framework for building frontend applications and interfaces from scratch. With concise, practical, and clear examples, this book takes web developers step-by-step through the tools and libraries in the Vue.js ecosystem and shows them how to create complete applications for real-world web projects.
You'll learn how to handle data communication between components with Pinia architecture, develop a manageable routing system for a frontend project to control the application flow, and produce basic animation effects to create a better user experience.
This book also shows you how to:
Create reusable and lightweight component systems using Vue.jsBring reactivity to your existing static applicationSet up a project using Vite.js, a build tool for frontend project code managementBuild an interactive state management system for a frontend application with PiniaConnect external...
Author(s): Maya Shavin
Publisher: O'Reilly Media
Year: 2023
Language: English
Pages: 347
Preface
Conventions Used in This Book
Using Code Examples
O’Reilly Online Learning
How to Contact Us
Acknowledgments
1. Welcome to the Vue.js World!
What Is Vue.js?
The Benefits of Vue in Modern Web Development
Installing Node.js
NPM
Yarn
Vue Developer Tools
Vite.js as a Builder Management Tool
Create a New Vue Application
File Repository Structure
Summary
2. How Vue Works: The Basics
Virtual DOM Under the Hood
The Layout Update Problem
What Is Virtual DOM?
How Virtual DOM Works in Vue
The Vue App Instance and Options API
Exploring the Options API
The Template Syntax
Creating Local State with Data Properties
How Reactivity in Vue Works
Two-Way Binding with v-model
Using v-model.lazy Modifier
Binding Reactive Data and Passing Props Data with v-bind
Binding to Class and Style Attributes
Iterating over Data Collection Using v-for
Iterating Through Object Properties
Make the Element Binding Unique with Key Attribute
Adding Event Listener to Elements with v-on
Handling Events with v-on Event Modifiers
Detecting Keyboard Events with Key Code Modifiers
Conditional Rendering Elements with v-if, v-else, and v-else-if
Conditional Displaying Elements with v-show
Dynamically Displaying HTML Code with v-html
Displaying Text Content with v-text
Optimizing Renders with v-once and v-memo
Registering a Component Globally
Summary
3. Composing Components
Vue Single File Component Structure
Using defineComponent() for TypeScript Support
Component Lifecycle Hooks
setup
beforeCreate
created
beforeMount
mounted
beforeUpdate
updated
beforeUnmount
unmounted
Methods
Computed Properties
Watchers
Observing for Changes in Nested Properties
Using the this.$watch() Method
The Power of Slots
Using Named Slots with Template Tag and v-slot Attribute
Understanding Refs
Sharing Component Configuration with Mixins
Scoped Styling Components
Applying CSS to a Child Component in Scoped Styles
Applying Scoped Styles to Slot Content
Accessing a Component’s Data Value in Style Tag with v-bind() Pseudo-Class
Styling Components with CSS Modules
Summary
4. Interactions Between Components
Nested Components and Data Flow in Vue
Using Props to Pass Data to Child Components
Declaring Prop Types with Validation and Default Values
Declaring Props with Custom Type Checking
Declaring Props Using defineProps() and withDefaults()
Communication Between Components with Custom Events
Defining Custom Events Using defineEmits()
Communicate Between Components with provide/inject Pattern
Using provide to Pass Data
Using inject to Receive Data
Teleport API
Implementing a Modal with Teleport and the