ES6解构赋值:
栗子:
var person= {
name:'haha',
age:'18'
}
//ES5
var name = person.name
var age = person.age
//ES6
var {name, age} = person
ES6对象声明:
var name ="haha"
//es5
var person = {
name:name,
say : function(){
console.log(this.name)
}
}
//es6
var person = {
name,
say () {
console.log(this.name)
}
}
ES6模块语法:
导入导出对应
export default routes
import routes from './routes'
导出什么值获取什么值。
export default function search(){
}
import search from './xx.js'
//search是一个函数
export routes
import {routes} from './routes'
箭头函数
//es5
function resolve(res) {
that.items = res.books;
}
//es6
var resolve = res => {
this.items = res.books;
}