logo资料库

Pro Vue.js 2(pdf英文原版-2018版).pdf

第1页 / 共728页
第2页 / 共728页
第3页 / 共728页
第4页 / 共728页
第5页 / 共728页
第6页 / 共728页
第7页 / 共728页
第8页 / 共728页
资料共728页,剩余部分请下载后查看
Table of Contents
About the Author
About the Technical Reviewer
Part I: Getting Started with Vue.js
Chapter 1: Your First Vue.js Application
Preparing the Development Environment
Installing Node.js
Installing the @vue/cli Package
Installing Git
Installing an Editor
Installing a Browser
Creating the Project
Understanding the Project Structure
Starting the Development Tools
Replacing the Placeholder Content
Adding a CSS Framework
Styling the HTML Elements
Adding Dynamic Content
Displaying the List of Tasks
Adding a Checkbox
Filtering Completed Tasks
Creating New Tasks
Storing Data Persistently
Adding the Finishing Touches
Summary
Chapter 2: Understanding Vue.js
Should I Use Vue.js?
Understanding Round-Trip Applications
Understanding Single-Page Applications
Understanding Server-Side Rendering
Understanding Application Complexity
What Do I Need to Know?
How Do I Set Up My Development Environment?
What Is the Structure of This Book?
Part 1: Getting Started with Vue.js
Part 2: Working with Vue.js
Part 3: Advanced Vue.js Features
Are There Lots of Examples?
Where Can You Get the Example Code?
Where Can You Get Corrections for This Book?
How Can You Contact Me?
Summary
Chapter 3: HTML and CSS Primer
Preparing for This Chapter
Understanding HTML Elements
Understanding Element Content
Understanding Element Content Restrictions
Understanding Void Elements
Understanding Attributes
Quoting Literal Values in Attributes
Applying Attributes Without Values
Examining the Live HTML Document
Understanding Bootstrap
Applying Basic Bootstrap Classes
Using Contextual Classes
Using Margin and Padding
Using Bootstrap to Create Grids
Using Bootstrap to Style Tables
Using Bootstrap to Style Forms
Summary
Chapter 4: Essential JavaScript Primer
Preparing for This Chapter
Using Statements
Defining and Using Functions
Defining Functions with Parameters
Using Default and Rest Parameters
Defining Functions That Return Results
Using Functions as Arguments to Other Functions
Using Arrow Functions
Using Variables and Types
Using the Primitive Types
Working with Booleans
Working with Strings
Using Template Strings
Working with Numbers
Using JavaScript Operators
Using Conditional Statements
The Equality Operator vs. the Identity Operator
Explicitly Converting Types
Converting Numbers to Strings
Converting Strings to Numbers
Working with Arrays
Using an Array Literal
Reading and Modifying the Contents of an Array
Enumerating the Contents of an Array
Using the Spread Operator
Using the Built-in Array Methods
Working with Objects
Using Object Literals
Using Variables as Object Properties
Using Functions as Methods
Copying Properties from One Object to Another
Understanding JavaScript Modules
Creating and Using a Simple JavaScript Module
Using a Simple JavaScript Module
Defining Multiple Features in a Module
Changing Module Feature Names
Importing an Entire Module
Combining Multiple Files in a Module
Importing Individual Features from a Multifile Module
Understanding JavaScript Promises
Understanding the Asynchronous Operation Problem
Using a JavaScript Promise
Simplifying the Asynchronous Code
Summary
Chapter 5: SportsStore: A Real Application
Creating the SportsStore Project
Adding Additional Packages
Incorporating the CSS Stylesheets into the Application
Preparing the RESTful Web Service
Starting the Project Tools
Creating the Data Store
Creating the Product Store
Creating the Product List
Adding the Product List to the Application
Filtering the Price Data
Adding Product Pagination
Changing the Product Page
Changing the Page Size
Adding Category Selection
Using the RESTful Web Service
Summary
Chapter 6: SportsStore: Checkout and Orders
Preparing for This Chapter
Creating the Shopping Cart Placeholder
Configuring URL Routing
Displaying a Routed Component
Implementing the Cart Features
Adding a Module to the Data Store
Adding the Product Selection Feature
Displaying the Cart Contents
Creating a Global Filter
Testing the Basic Cart Features
Making the Cart Persistent
Adding the Cart Summary Widget
Adding the Checkout and Orders Features
Creating and Registering the Checkout Components
Adding Form Validation
Adding the Remaining Fields and Validation
Summary
Chapter 7: SportsStore: Scaling and Administration
Preparing for This Chapter
Dealing with Larger Amounts of Data
Improving Page Navigation
Reducing the Amount of Data Requested by the Application
Determining the Number of Items
Adding an Item to the Array of Pages
Updating the Components to Use Actions
Adding Search Support
Starting the Administration Features
Implementing Authentication
Extending the Data Store
Adding the Administration Components
Adding the Route Guard
Adding the Administration Component Structure
Implementing the Order Administration Feature
Summary
Chapter 8: SportsStore: Administration and Deployment
Preparing for This Chapter
Adding the Product Administration Features
Presenting the Product List
Adding the Editor Placeholder and URL Routes
Implementing the Editor Feature
Deploying SportsStore
Preparing the Application for Deployment
Preparing the Data Store
Preparing the Authentication Component
Loading the Administration Features On-Demand
Creating the Data File
Building the Application for Deployment
Testing the Deployment-Ready Application
Deploying the Application
Creating the Package File
Creating the Docker Container
Running the Application
Summary
Part II: Vue.js in Detail
Chapter 9: Understanding Vue.js
Preparing for This Chapter
Adding the Bootstrap CSS Framework
Running the Example Application
Creating an Application Using the DOM API
Understanding How the DOM API Application Works
Creating a Vue Object
Adding Data to the Vue Object
Adding an Event Handler
Correcting the Message
Understanding the Vue Object Structure
Introducing a Component
Registering and Applying the Component
Separating the Template from the JavaScript Code
Using Separate JavaScript and HTML Files
Summary
Chapter 10: Understanding Vue.js Projects and Tools
Creating a Vue.js Development Project
Configuring the Linter
Completing the Project Configuration
Understanding the Project Structure
Understanding the Source Code Folder
Understanding the Packages Folder
Using the Development Tools
Understanding the Compilation and Transformation Process
Understanding the Development HTTP Server
Understanding Hot Model Replacement
Understanding the Error Display
Using the Linter
Customizing the Linter Rules
Debugging the Application
Exploring the Application State
Using the Browser Debugger
Configuring the Development Tools
Building the Application for Deployment
Installing and Using an HTTP Server
Summary
Chapter 11: Understanding Data Bindings
Preparing for This Chapter
Understanding the Elements of a Component
Understanding the Template Element
Understanding the Script Element
Understanding the Style Element
Resetting the Component in the Example Application
Displaying a Data Value
Using More Complex Expressions in a Data Binding
Calculating Values with Computed Properties
Understanding Reactivity and Computed Properties
Calculating Data Values with a Method
Calling Methods Directly from Data Bindings
Formatting Data Values with Filters
Configuring Filters Using Arguments
Chaining Filters Together
Summary
Chapter 12: Using the Basic Directives
Preparing for This Chapter
Setting an Element’s Text Content
Displaying Raw HTML
Selectively Displaying Elements
Selectively Displaying Adjacent Peer Elements
Choosing Between Sections of Content
Performing More Complex Selections
Selectively Displaying Elements Using CSS
Setting an Element’s Attributes and Properties
Using an Object to Configure Classes
Setting Individual Styles
Setting Other Attributes
Setting Multiple Attributes
Setting an HTMLElement Property
Summary
Chapter 13: Using the Repeater Directive
Preparing for This Chapter
Enumerating an Array
Using the Alias
Identifying the Key
Getting the Item Index
Understanding Array Change Detection
Understanding Update Problems
Enumerating Object Properties
Understanding Object Property Ordering
Repeating HTML Elements Without a Data Source
Using Computed Properties with the v-for Directive
Paging Data
Filtering and Sorting Data
Summary
Chapter 14: Handling Events
Preparing for This Chapter
Handling Events
Understanding Events and Event Objects
Using a Method to Handle Events
Combining Events, Methods, and Repeated Elements
Listening for Multiple Events from the Same Element
Using Event Handling Modifiers
Managing Event Propagation
Receiving Events in the Capture Phase
Handling Only Target Phase Events
Stopping Event Propagation
Preventing Duplicate Events
Using Mouse Event Modifiers
Using Keyboard Event Modifiers
Summary
Chapter 15: Working with Form Elements
Preparing for This Chapter
Creating Two-Way Model Bindings
Adding a Two-Way Binding
Adding Another Input Element
Simplifying Two-Way Bindings
Binding to Form Elements
Binding to Text Fields
Binding to Radio Buttons and Checkboxes
Binding to Select Elements
Using the v-model Modifiers
Formatting Values as Numbers
Delaying Updates
Removing Whitespace Characters
Binding to Different Data Types
Selecting an Array of Items
Using Custom Values for Form Elements
Using Custom Values for Radio Buttons and Select Elements
Validating Form Data
Defining the Validation Rules
Performing Validation
Responding to Live Changes
Summary
Chapter 16: Using Components
Preparing for This Chapter
Understanding Components as Building Blocks
Understanding Child Component Names and Elements
Using Component Features in Child Components
Understanding Component Isolation
Using Component Props
Using a Prop in a Parent Component
Using Prop Value Expressions
Creating Custom Events
Receiving a Custom Event from a Child Component
Using Component Slots
Using Named Slots
Using Scoped Slots
Summary
Part III: Advanced Vue.js Features
Chapter 17: Understanding the Component Lifecycle
Preparing for This Chapter
Understanding the Component Lifecycle
Understanding the Creation Phase
Understanding Component Object Creation
Understanding the Reactivity Preparations
Understanding the Mounting Phase
Accessing the Document Object Model
Understanding Update Phase
Understanding Update Consolidation
Using a Post-Update Callback
Observing Data Changes Using Watchers
Understanding the Destruction Phase
Handling Component Errors
Summary
Chapter 18: Loosely Coupled Components
Preparing for This Chapter
Creating the Product Display Component
Creating the Product Editor Component
Displaying the Child Components
Understanding Dependency Injection
Defining a Service
Consuming a Service via Dependency Injection
Overriding Antecedent Services
Creating Reactive Services
Using Advanced Dependency Injection Features
Using an Event Bus
Sending Events Using an Event Bus
Receiving Events from the Event Bus
Creating Local Event Buses
Summary
Chapter 19: Using RESTful Web Services
Preparing for This Chapter
Preparing the HTTP Server
Preparing the Example Application
Installing the HTTP Package
Simplifying the Components
Running the Example Application and HTTP Server
Understanding RESTful Web Services
Consuming a RESTful Web Service
Handling the Response Data
Making the HTTP Request
Receiving the Response
Processing the Data
Creating an HTTP Service
Consuming the HTTP Service
Adding Other HTTP Operations
Creating an Error Handling Service
Creating an Error Display Component
Summary
Chapter 20: Using a Data Store
Preparing for This Chapter
Creating and Using a Data Store
Understanding Separate State and Mutations
Providing Access to the Vuex Data Store
Using the Data Store
Inspecting Data Store Changes
Defining Computed Properties in the Data Store
Using a Getter in a Component
Providing Arguments to Getters
Performing Asynchronous Operations
Receiving Change Notifications
Mapping Data Store Features into Components
Using Data Store Modules
Registering and Using a Data Store Module
Accessing Module State
Using Module Namespaces
Summary
Chapter 21: Dynamic Components
Preparing for This Chapter
Preparing Components for Dynamic Lifecycles
Getting the Application Data
Managing Watch Events
Displaying Components Dynamically
Presenting Different Components in an HTML Element
Selecting Components Using a Data Binding
Understanding the Component Lifecycle
Automatically Navigating Around the Application
Using Asynchronous Components
Disabling Prefetch Hints
Configuring Lazy Loading
Summary
Chapter 22: URL Routing
Preparing for This Chapter
Getting Started with URL Routing
Providing Access to the Routing Configuration
Using the Routing System to Display Components
Navigating to Different URLs
Navigating Using HTML Elements
Understanding and Configuring URL Route Matching
Understanding URL Matching and Formatting
Using the HTML5 History API for Routing
Providing a Catchall Route
Using a Route Alias
Getting Routing Data in Components
Matching Routes Dynamically
Using Regular Expressions to Match URLs
Defining Optional Segments
Creating Named Routes
Dealing with Navigation Changes
Summary
Chapter 23: URL Routing Element Features
Preparing for This Chapter
Working with Router-Link Elements
Selecting the Element Type
Selecting the Navigation Event
Styling Router Link Elements
Responding to the Active Route
Changing the Active Route Classes
Creating Nested Routes
Planning the Application Layout
Adding Components to the Project
Defining the Routes
Handling Old URLs
Creating the Navigation Elements
Testing the Nested Routes
Using Named Router-View Elements
Summary
Chapter 24: Advanced URL Routing
Preparing for This Chapter
Using Separate Files for Related Routes
Guarding Routes
Defining Global Navigation Guards
Redirecting the Navigation Request to Another URL
Redirecting to a Named Route
Defining Route-Specific Guards
Understanding Guard Ordering
Defining Component Route Guards
Accessing the Component in the beforeRouteEnter Method
Loading Components on Demand
Displaying a Component Loading Message
Hiding the Outgoing Component During Loading
Creating Routing-Free Components
Summary
Chapter 25: Transitions
Preparing for This Chapter
Creating the Components
Configuring URL Routing
Creating the Navigation Elements
Getting Started with Transitions
Understanding the Transition Classes and CSS Transition
Understanding the Transition Sequence
Using an Animation Library
Switching Between Multiple Elements
Applying a Transition to URL Routed Elements
Applying a Transition for an Element’s Appearance
Applying Transitions for Collection Changes
Using Transition Events
Using the Enter and Leave Events
Drawing Attention to Other Changes
Summary
Chapter 26: Extending Vue.js
Preparing for This Chapter
Creating Custom Directives
Understanding How Directives Work
Using Custom Directive Expressions
Using Custom Directive Arguments
Using Custom Directive Modifiers
Communicating Between Hook Functions
Defining Single Function Directives
Creating Component Mixins
Creating a Vue.js Plugin
Creating the Plugin
Using a Plugin
Summary
Index
分享到:
收藏