Initialize a project
Install some dependencies
NPM Install name--save
For example NPM install Vue Axios Bootstrap--save
--save that both development and online use
--save Dev says start, throw away
Vue Summary1. Directives
V-show Toggle Display hidden, frequent display use
V-IF based on conditional statements can show hidden, infrequently show hidden use
V-else in front of the v-if with the use, if the front v-if not set up the case
V-model the key to bidirectional data binding, view changes
V-cloak prevent flicker in CSS define [V-cloak]{display:none}
V-once control bound content will not be monitored again change is usually used in conjunction with V-model
V-html parse the tag inside the data and insert it into the binding node.
V-text bound data, and {{}} equivalent, but can be anti-flicker
V-for loop Syntax-no index notation item in ARR syntax two-band index notation (item,index) in arr v-for can be nested
V-on for listening DOM events, shorthand @
V-bind for binding properties, shorthand:
V-style Write inline style, basically does not have any effect
Stop bubbling
E.cancelbubble=true;
E.stoppropagation ();
@click. Stop
modifier
You can add some modifier symbols after the time
@click. Stop blocking bubbling
@click capture time captures, first capture to target and then bubble
@click. Self only triggers a function when clicked on itself, other bubbles, skipping this function
@click. Prevent block default events, such as a tag click Jump, plus this @click.prevent, prevents the default property href to jump
ref= "Wo" binds an identity to a node
once the instance is created, add one more data
2 instantiating a Vue life cycleinstantiate a Vue function new Vue ({})
properties that are not commonly used in Vue
Beforecreate () {}
Beforemount () {}
Determine if there is an El attribute, at this time, there are template templates, using the template, do not use the #app node internal rendering
Basic No
BeforeUpdate () {}
When the page data is sent, it executes, if the page uses this data
Basic no computed{} calculation properties basically all done.
Destroyed () {}
Localstorage Cache
Localstorage.setitem (' Cached name ', ' cached value ');
Localstorage.getitem (' Cached name ')
We normally cache the object as a string cache json.stringify ()
Then take out the cached data and convert the string to a JSON object Json.parse ()
one of the asynchronous programming Promise
Resolve Callbacks to Hell
Synchronize requests, waiting in turn
Promise has three states, success, failure, waiting
Promise has two parameters, which is actually two function types
The first parameter, resolve, represents a successful
The second parameter, reject, represents a failure
Promise comes with then method,
Array Common Operations
Reverse () Reverse Array
[1,2,3,4].reverse ()
Join ()
Receives a parameter, which is a string used as a delimiter, and then returns a string containing all the array items
Pop ()
Concat ()
Merging arrays
[1,2].concat ([3,4])
[1,2,3,4]
Map map
Console.log (function (item) {Arr=[1,1,3].map
return item+1;
}))
ForEach Loop
Loop array
Filter filters
Filters an array by condition, returns the filtered array
Console.log ([1,2,3].filter (function (item) {
if (item>1) {
return Item
}
}))
The result is [2,3].
Find Lookup
Console.log ([1,2,3].find (function (item) {
if (item==1) {
return item;
}
}))
Includes method
Console.log ([1,2,3].includes (1))
Some method
To determine if the current array is eligible, return ture, no false
Console.log ([1,2,3,6].some (function (item) {
if (item>1) {
return Item
}
}))
The result is true that there are currently elements greater than 1
Every method
Console.log ([1,2,3].every (function (item) {
if (item>1) {
Return item
}
}))
Console.log ([1,2,3].reduce (Prev,next,index,arr) {
return prev+next;
})
Procedure, the first option value is 0, plus the first item has a value of 1
The second time, the previous cumulative value is 1, plus the value of the second item is 2
The third time before the value is 3, plus the value of the third item is 3
-So the result is 6
Vue.js Basic Knowledge Summary