- Node.JS installation
a) Why do you want to install it: Chrome V8 engine is based on the JavaScript runtime environment. Let JavaScript to run server-side development platform.
B) After installing node.js installed, we can not use in the idea, so we're going after node.js installed the plug-ins installed on the idea, in which IDEA command line to run the command node -v to check whether the installation was successful.
Common Commands c) IDEA is installed inside Vue
i. Npm install vue Vue project which downloads
ii. Npm uninstall vue unloading Vue
. Iii list module: npm ls
. iv ④ unloading modules: npm Uninstall VUE
⑤ update module: npm Update VUE
⑥ run project: npm RUN dev / the Test / Online
⑦ compile the project: npm RUN Build
// objects deconstruction
let person = {name:"哪它",age:12,sex:true}
let {name,age,sex} = person;
console.debug(name,age,sex);
- Vue Getting Started
a) adding a file in a web below Vue
b) introducing vue.min.js file in the page
- Vue life cycle
a)
- Examples of label mount el VUE
a) Id way of mounting
<div ID = "App">
<h1 of> Message {} {} <h1 of>
</ div>
new new VUE ({
EL: "# App"
Data: {
Message: "Data"
}
})
b) Class mount that
Id way of mounting
<div class = "App">
<h1 of> Message {} {} <h1 of>
</ div>
new new VUE ({
EL: "App."
Data: {
Message: "Data "
}
})
- VUE usual methods (methods properties which can write methods)
a) a method call to an object method name Vue.
new new VUE () say ().;
b) two-way data binding VUE {{say ()}}
- VUE understanding of architecture
a) introducing the MVVM (Model-View-ViewModel) mode, a mode different from the MVC
Grammar b) VUE expression
c) VUE ternary operator
d) VUE string operations
e) Vue object action
f) Vue array operation
- VUE instructions
a) Vue instruction with a v- prefix special tag attributes, the expected value of a single attribute instruction JavaScript expression.
<HTML tag V-XXX = ""> <HTML tag>
b) V-bind command, all the attributes of the object at one time bound over
<IMG the bind-V = "imgAttr" />
imgAttr : {
the src : "Image / 1.jpg" ,
width : 200 is,
height : 300,
}
c) V-for instruction value traversing
div ID = "App" >
<-! iterate ->
< div V-for = "V in hobbys" > {{V}} </ div >
<! - traversal string ->
< div V-for = "V in MSG" > {{V}} </ div >
<-! traversing digital ->
< div V-for = "V in NUM" > {{ }} V </ div >
<! - traverse the object ->
<! -
traverse the object
val: the representative value traversing
name:Property name
index: location
-->
<div v-for="(val, name, index) in employee">{{name}}:{{val}}:{{index}}</div>
</div>
<script type="text/javascript">
new Vue({
el:"#app",
data:{
hobbys:["1","2","3"],
msg:"aghfjagf",
num:10,
//对象
employee:{
name:"qiangqiang",
age:19,
sex:true
}
}
})
</script>
d) V-HTML and the TEXT-V
< div ID = "App" >
<-! HTML loads Properties tab ->
< div V =-HTML "MSG" > {{MSG}} </ div >
< ! - the text will not load the tag attributes ->
< div V-text = "MSG" > {{MSG}} </ div >
</ div >
< Script type = "text / JavaScript" >
new new Vue ( {
EL : "#app" ,
Data : {
MSG :"<h1>Chinese people</h1>"
}
})
</script>
</body>
e) V-model instructions
Note: two-way binding to the array to be used when the check box, checkboxValue: [], the other is in normal use
i. can be bound to the three input select textarea Tags
ii. <div id="app">
<H1> bound to form element input type = text of </ h1>
姓名:<input type="text" v-model="inputValue"><br/>
The data values: {{inputValue}}
<H1> type = input is bound to form elements of checkbox </ h1>
Playing basketball: <input type = "checkbox" v-model = "checkboxValue" value = "basketball"> <br/>
Soccer: <input type = "checkbox" v-model = "checkboxValue" value = "football"> <br/>
The data values: {{checkboxValue}}
<H1> type = input is bound to form elements of the radio </ h1>
Playing basketball: <input type = "radio" v-model = "radioValue" value = "basketball"> <br/>
Soccer: <input type = "radio" v-model = "radioValue" value = "football"> <br/>
The data values: {{radioValue}}
<H1> bound to textarea element </ h1>
Profile: <textarea v-model = "textareaValue"> </ textarea> <br/>
The data values: {{textareaValue}}
<H1> elements bound to the select radio </ h1>
技能:<select v-model="skills">
<option value="java">java</option>
<option value="php">php</option>
<option value=".net">.net</option>
</select><br/>
The data values: {{skills}}
</div>
was app = new Vue ({
el: "#app",
data: {
inputValue: "initialization value"
checkboxValue: [ "football"],
radioValue: "playing basketball"
textareaValue: "You are a good software engineer!"
skills: "java",
}
});
f) V-show instruction
I. Role:
The expression of the truth value, the switching element attribute display CSS. When conditions change command triggering the transition effect.
When the v-show is false, adds display in css tag: none:
g) V-if instruction
i.
h) V-else instruction
i.
i) V-else-if instruction
i.
- VUE components
a) local and global components components: effect of different ranges
- ES6
a) Constant:
// define a constant (necessary for assignment, and can not be modified)
const val = "You can not repair my!";
console.debug(val);
b) definition array
a mode i:. Let [a, b, c] = [ "1", "2", "3"]
. Ii Second way: Let arr = [ "1", "2", "3"] Assignment -> Let [a, b, c] = arr;
c) the definition of the object
. i Let arr = {name = "q", age = 18}
function deconstruction
let {name, age} = arr ;
- Console.debug(name,age);
d) a function of an arrow
. Let say I = () => {
console.debug ();
}
is called: say ();
Note: If the function arrows if there is only one method body code can be omitted {}
. ii hook function:
<div ID = "App">
{{}} Hello
</ div>
js:
Vue new new VM = var ({
EL: "App #",
Data: {
Hello: '' Hello // initialized to empty
},
Created () {
this.hello = "!! Hello, World I was born";
}
} )
For example: created behalf after vue instance is created; we can define a function created in Vue, the representative of this period constructor:
e) function deconstruction
Const person = {name: "aaa ", age: 19}
traditional way
function say (P) {
console.debug ( "Name": + p.name)
}
say (Person)
ES6 Arrow mode (also the method is used in a subject which defines)
the let say = ({name, Age}) => {
console.debug ( "name" + name)
}
say (Person)
f) Promise better AJAX request is a
traditional AJAX request a callback function which has
Ajax (URL, function (B)) {
}
i. <script>
/**
* Resolve: After a successful function should be performed
* Reject: after the failure of the function should be performed
*/
var promise = new Promise(function(resolve, reject) {
// 5 seconds after execution
setTimeout(function () {
let num = Math.random();
if(num>0.5){
// successful execution of the code
resolve ( "buddy child succeed back");
}else{
// code execution failed
reject ( "melon Wazi ...");
}
},2000)
})
// this is to perform the corresponding function
promise.then(function(msg){
console.debug(msg)
}).catch(function(msg){
console.debug(msg)
})
</script>
Array and object definitions
<div id = "app">
=== MSG}} {{{{}} <br /> Age
/// Get Value
Hobbies {{}} == {{hobbies [0]}} <br />
{{dept}} {{dept.name}}
</div>
<script>
new view ({
// el: Mount (el mount for complete functionality)
el:"#app",
// represents the data, the data can go to get the vue mount container
data:{
msg: "what it"
age:6,
hobbys: [ "eat", "sleep", "play Peas'],
dept:{
id:1,
name:"it部"
}
}
})
</script>
The method defined in
<! - may be called directly in the expression {{say ()}} - >
<div id="app">
{{msg}}
</div>
<script>
var v = new Vue ({
el:"#app",
data:{
msg: "Which it"
},
// define all methods in this Vue
methods:{
say(){
this.msg = "Which bite"
}
}
})
alert(0)
// The first invocation
v.say();
v-model label
g) Specification Modular
a stuff inside the inside with b, b in need turned inside out, and then a can in which b
h) Node.js (small applications)
i. Download
Fool-installation, installation, Idea which is not supported, you need to install plug-ins node.js