// Minimum Cost - Asymptotic delta @ vue installation: Method 1 - vue introduced directly script file Method 2-npm install the install NPM vue // Method 3 vue the CLI command line provided official cli, single page to quickly build complex scaffolding // <-! development version of the console contains useful warning -> {/ * <Script src = "https://cdn.jsdelivr.net/npm/vue/dist/vue.js"> < / Script> * /} // <-! generation version, optimized for speed and volume -> {/ * <Script the src = "https://cdn.jsdelivr.net/npm/vue"> </ Script > * /} / * <div ID = "App"> <App-NAV> </ NAV-App> <App-View> <App-Sidebar> </ App-Sidebar> <App-Content> </ APP- Content> </ App-View> </ div> * / // cross-component data stream - custom event communications - Construction of Integrated Tools @ vue Examples var vm = new Vue ({// Options}) vue vue instance a root // application created by a new Vue, and a nested reusable component tree composition. // PS: All components are vue vue example and the same option acceptance object. // Data and Method: When a vue instance is created, all the properties it is added to the data object in response formula vue systems. // When these attribute values change, the view will generate a response that matches the new value updates. // Data Objects var Data = {A:}. 1 // object instance is added to a vue var vm = new new Vue ({Data: Data}) // properties obtained on this example returns the corresponding data field in the source vm data.a to true // == II.A // set the property also affects the original data vm.a = 2; data.a // 2 data.a =. 3; vm.a. 3 // // when data changes when, the view is re-rendered. ps: instance is created only when data is present in response to an attribute type. // That is when the newly added attribute changes will not be updated view. so if you need a property later, it initially does not exist, you can set an initial value // $ Watch vm. Watch $ ( 'A', function (newValue, oldValue) { // This callback will be in `vm after .a` change calls }) // vue each instance when it is created to go through a series of initialization processes - such as setting data monitor - compiled templates - mounts instance to update the DOM and DOM when data changes, // while this process will run some hook function is called the life cycle. Vue new new ({ EL: '# App', Data: { A:. 1 }, Created () { // lifecycle hook pointing in this context it calls vue example the console.log (this.a) } }) // lifecycle hook function // new Vue () beforeCreate created beforeMount mounted beforeUpdate updated Destroyed beforeDestroy // on the underlying implementation vue template compiled into virtual DOM rendering function, in conjunction with response system, vue intelligently calculated minimum number of components need to be rendered, and the DOM // minimize the number of operations. // Instruction: v- prefix with special characteristics, the expected value of a single instruction js characteristic expression, v- identifying characteristics for a particular template vue. Accused instruction - when the expression value will change in response to their impact associated // Formula acts on the DOM, such as v-once interpolation can be performed at one time, when the data changes, the content is not updated at the interpolation. <span V-Once> MSG {{}} </ span> // V-IF will operate according to an expression of true and false values <P-V IF = "Seen"> DSSD </ P> // Double braces grammar html not act on the characteristics of this case should be used v-bind command <div v-bind: id = "dynamicId"> </ div>, i.e. the binding properties by v-bind // V-oN event listener dom < a v-on: click = " do"> </a> // Calculation and listener properties // recommended for any complicated calculation logic computed property // Calculation property cache - a method similar functions may be implemented as a method and a function definition attribute calculation, except that the calculation is based on their property responsive rely on caching, // only they will be re-evaluated when the associated responsive rely change, that as long as the property value has not changed, many visits to calculate property returns before the results immediately, without having to // again execution of the function. The method, each time re-rendering method will always execute the function call again. Use cache can improve performance. // Calculation Properties - The listener properties // changed data vue instance by listening to the response observed and properties vue. ps: when data needs to change with additional data to calculate recommended properties instead of abusing watch // Calculate the property setter ps: calculate the default attribute only getter, setter when needed to provide the recommended watch operation // listener when you need to perform asynchronous data changes or when the overhead of a larger operation // Class and Style Bind // v-bind operation can be used to bind the class list and inline style element (string result calculated by expression). Because string concatenation cumbersome and error-prone, so when // the v-bind for class and style, vue.js do a special enhancements. In addition to the result of the expression of type string type may also be an object or an array. // object syntax: v-bind: class objects that can be transferred, in order to dynamically switch the class, more properties can be passed in the object dynamically switching the plurality of class // <div class = "statics to" the bind-V: class = "{Active: isActive, 'text-Danger': hasError}"> </ div> // the bind PS-V: class instructions may coexist with common class attribute. // do not have to bind data objects defined inline in a template: / * <div the bind-V: class = "classObj"> </ div> Data: { classObj: { Active: to true, 'text-Danger': // v-if the condition is true rendering, it will ensure that during the handover event listener and subcomponents within the conditional block properly destroyed and rebuilt. // v-if inert, rendering the initial condition is false then do nothing - until the first condition becomes true only when conditions start rendering block. // v-show, no matter what the initial conditions, the elements will always be rendered, and simply based on css switch. // ps: v-if there will be higher switching overhead, and v-show has a higher initial rendering overhead. // v-for an array corresponding to the elements of a set, a list of rendering @ mutating: change call these methods the original array, such as a push () - pop () - shift () - unshift () - splice () -sort () - Reverse () // non-variant method: does not change the original array, always returns a new array, such as filter () - the concat () - Slice () // priority than for V- v-if, when some of the items just as render nodes, can use this priority mechanism, usually not recommended. // If the object is conditional skip execution cycle, may be v-if the outer element is placed. // event handler: v-on instruction can listen dom events, and run some js code that when triggered; v-on can receive a call the method name of // v-model command in the form <input> <textarea> and < select> create a two-way data binding on the element. It automatically selects the correct method to update the control type // elements responsible for monitoring user input events to update the data, and some extreme scenarios do special treatment. ps: v-model ignores all form element value / checked / initial value // selected characteristics and the total vue data as the data source instance. // ps: v-model using different attributes for different input elements inside and throw different events: text and textarea elements using the property value and input events; // checkbox and radio use checked property and change events; select field value as a prop and change as an event; // Model v-way binding implementation principles: v-bind bind responsive data, event trigger input and pass data , monitor input events and the carrying value of the input event // passed to the v-model property is bound. Both bound data, and add event listener input a {/ * <= input V-Model "STH"> * /} {/ * <input the bind-V: value = "STH" V-ON: input = " = $ event.target.value STH "/> * /} // Register components - global Register Register & topical // Vue.component ( 'component-name', {...}) / * var = {} ComponentA new new VUE ({ EL: '# App', components: { 'component-a': ComponentA } }) * / // PS: registered locally unavailable assembly in its sub-components, if desired in ComponentB ComponentA available, then: / * var = {... ComponentA 'Component-A': ComponentA }, // ... } * / / * Import from ComponentA './ComponentA.vue'; Export default { Components: { ComponentA }, // ... } * / // components named recommendation letters all lowercase and must contain a hyphen // define the component name of two ways: separated by dashes name also used when referring to the way the dash; capitalized name, you can dash when // references in the form of references can be capitalized in the form of reference. // by prop transfer data to sub-components // prop are custom properties you can register in the assembly, when a value is passed to the characteristics of a prop, it became a property of the component instance. // props can be included in the option list of acceptable components of the prop.