v-bind
Directive<div>
element to a class
Bind an <img>
element to an image file
Change the font size
Change the font size in a different way
Change the font size in yet a different way
Change the background color
Use v-bind
and a JavaScript condition to change the background color
Bind a <div>
element to a class
Bind a <div>
element to a class, conditionally
Bind a <div>
element to a class, conditionally, with a data property
Use the v-bind
short hand
Change opacity to reveal an image using an input range element
Assign a class when images created with v-for
are clicked
We see that CSS rules set with class
and v-bind:class
are merged
More than one class can be set with v-bind:class
, with comma separation
CSS rules are defined with v-bind:style
, using both camel case and kebab case notation
Classes are assigned with array syntax
v-if
Directivev-if
, v-else-if
and v-else
Display a message if a certain text contains the word 'pizza'
Display a message and an image if a certain text contains the word 'pizza'
Display different messages and images if a certain text contains the word 'pizza' or 'burrito'
v-show
Directive<div>
element based on a data property
Explore the differences between v-show
and v-if
v-for
Directivev-on
Directivev-on:click
for elements generated with v-for
The v-on
shorthand @
is used
.once
modifier makes the alert only appear once when a button is clicked
The keydown
keyboard event calls a method that writes the key to the screen
The .s
modifier triggers an alert when the 'S' key is pressed
The .s
and .ctrl
modifiers trigger an alert when the 'S' and 'ctrl' keys are pressed simultaneously
The background color changes when the <div>
element is right clicked
The background color changes when the <div>
element is right clicked as the 'ctrl' key is pressed
The right click drop down menu is prevented with the .prevent
modifier
The left click changes image when the 'shift' key is pressed
v-model
Directivev-model
Explore the two-way binding feature provided by v-model
A checkbox changes a boolean data property
A shopping list
A shopping list where items can be marked as found
A dynamic restaurant order form
Choose a favorite animal with radio buttons, <input type="radio">
Choose food you like with checkboxes, <input type="checkbox">
Choose a car from a drop-down list, <select>
Select multiple cars, <select multiple>
Read only form input, <input type="file">
Register height, <input type="range">
Choose a color, <input type="color">
Write a product review, <textarea>
v-for
Components with props are created with v-for
and the key
attribute
This faulty example demonstrates that the key
attribute is needed
This example demonstrates that the key
attribute can fix problems
style
attribute falls through to the component
The style
attribute falls through to the component, and is merged with the inline styling
The $attrs
object is used to define where the fallthrough attributes belong
scoped
attribute
v-slot
directive is used to direct content to a specific slot
The v-slot
shorthand is #
Receive data from a scoped slot
Scoped slots created with v-for
send data to its parent
Scoped slots created from an array of object send data to its parent
A text is sent from a scoped slot without thev-bind
directive
Scoped slots are named
Named scoped slots send different data to App.vue.
<KeepAlive>
component the components are not cached
The<KeepAlive>
component caches the components
Only the specified component is cached with the<KeepAlive include="CompOne">
code
The specified component is NOT cached with the<KeepAlive exclude="CompOne">
code
Two components are specified to be cached with the<KeepAlive>
component
The last two visited components are specified to be cached with the<KeepAlive>
component
<div>
element is moved to the root of the<body>
element in the DOM
Scoped styling and script still works for teleported<div>
element
$refs
object is used to replace text in a <p>
element
The $refs
object is used to replace text from one <p>
element into another
The $refs
object is used to put the value from an <input>
element into a <p>
element
<li>
elements with the ref attribute, created with v-for
, are collected in the $refs
object as an array
beforeCreate
lifecycle hook
The created
lifecycle hook
The beforeMount
lifecycle hook
The mounted
lifecycle hook
The mounted
lifecycle hook is used to put the cursor inside an<input>
element
The beforeUpdate
lifecycle hook
The updated
lifecycle hook
The updated
lifecycle hook generates an infinite loop
The beforeUnmount
lifecycle hook
The unmounted
lifecycle hook
The errorCaptured
lifecycle hook
The errorCaptured
lifecycle hook retrieves information about the error
The renderTracked
lifecycle hook
The activated
lifecycle hook
The activated
, deactivated
, and other lifecycle hooks
<div>
element is rotated with the CSS transition
property
A circular <div>
element bounces left-to-right with the CSS @keyframes
property
A <p>
element is toggled with a button
A <p>
element inside the <Transition>
component fades out when it is removed
A <p>
element slides in and out when it is toggled
A <p>
element has separate background colors during 'enter' and 'leave'
<p>
elements are animated differently, using the name
prop to differentiate the <Transition>
components
The after-enter
event triggers a <div>
element to be displayed
A toggle button triggers the enter-cancelled
event
The appear
prop starts the <p>
element animation right after the page is loaded
Flip through images with animation on 'enter' and 'leave'. A new image is added before the old image is removed
Flip through images with animation on 'enter' and 'leave'. The mode="out-in"
prevents new images to be added until the old image is removed
Switching between components is animated
v-for
v-for
, using <TransitionGroup>
Dice can be added or removed, added dice are animated using <TransitionGroup>
Dice can be added or removed, both added and removed dice are animated using <TransitionGroup>
Dice can be added, removed shuffled or sorted, all animated using <TransitionGroup>
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!