vue learning the basics (b)

What is vue

3 the front end of the carriage frame angular Google Inc. m (data) v (view) c (controller) two-way data binding react facebook (Feisibuke) layer frame virtual view view dom VUE Yuxi particular virtual two-way data binding dom + a a progressive framework for building user interfaces entry lowest difficulty

Why learn vue

Efficient 1. Run the high efficiency operation of virtual real dom dom reduce the operating efficiency of the project greatly improved 2. Development of high efficiency using a component-based development to focus the developer's liberation from operating out of the dom, transferred to the data manipulation

Fall in love with vue 3 5

What is loving thoughts all the time to write a page using vue abandon the original wording of the second phase (direct operation dom)

vue instantiation

1. Download introducing 
2. dom that find a dom element to be controlled vue
3 vue instantiated in the js

Data Binding

Instruction directive

The instructions are back with an expression or variable

Vue directly embedded instructions provided inside a custom instructions to implement custom command certain functions

Conditions rendering can control the display of an element or hide the v-show by Style Run the display: none v-IF direct control of the div element with or without (v-else v-elseif) event bindings use vue events v-on: events name (and the name of the event native js unanimous): a function to events @ event name: event handler event handlers written in the instance configuration items motheds default parameter handler is an event object if you need to pass additional parameters of the event object need `$ event manual transmission property binding v-bind properties of elements are fixed with the value attribute binding can be achieved with the rear property variable or expression v-bind: attribute name to be bound <img v-bind: = the src ''> : to be bound property name <img: src = ''> renderer list v-for numeric string array form <td v-for = "( item, index) in / of the data source"> < / TD> <TD V-for = "(value, Key, index) in / of the data source"> </ TD>

Model-way data binding v v-equivalent Model v-on event binding properties of v-bind and aggregate form elements and data changes in the data binding either party the other party will follow the change

  1. Form elements can use

  2. Components can also be used

Custom command

Global custom command

Vue.directive ( 'command name', { 
insterted (el) {
  element el custom command bindings
}
})
V- custom command name

Custom local specifies which register is used in which the can register Examples of local components and custom instruction

Vue new new ({ 
directives: {
  custom command name: {
    inserted The (EL) {     }   } } })




Package

2. 1. Create the component register component assembly 3. distinguish the local component is global component different positions registered global Vue.component ( 'component name' {} assembly CI) local new new Vue ({ ... Components : { component name: { CI }, Hehe: { Template: '# Hehe', components: { xixi: { Template: '# xixi', components: { .... } } } } } })

Examples of the component configurations and configuration differences

El template binding element data DATA function data objects custom instruction directive directive methods methods methods assembly calculating properties listening ....

Communication Components

In the components and their instance data they can control only the

  1. Sons communication props parent element control sub-assembly to control their parent component data changes, the data after the change by props custom Crossing subassembly

  2. $ Emit child-parent communication sub-components of the control of the parent component data parent component to control their own data changes, the control function custom events passed through emit sub-assemblies for the child component calls

  3. Brothers Communications a. To enhance the status b. Event bus c. Global state management

vue scaffolding tool

Taobao will be replaced by a mirror image npm npm install -g @ VUE / cli VUE -V version appears to create a new file into the file directory execute vue create name (name easily play) into the project directory execute npm run serve

Guess you like

Origin www.cnblogs.com/Frank000000/p/12664301.html