改变原始数组
push()
pop()
shift()
unshift()
splice()
sort()
reverse()
不改变原数组
filter()
contat()
slice()
实例:
computed:{
filterBooks(){
return this.books.filter(function(book){
return book.name.match(/javascript/)
})
},
sortBooks(){
return this.lists.sort(function (a,b) {
return a.name.length<b.name.length
})
}
}
mounted(){
this.books.push({ //push数组方法,视图直接改变
name:'《css3实战》',
author:'huiyh'
});
this.books=this.books.concat([{ //concat数组方法,需更新原数组
name:'《html5实战》',
author:'lala'
}])
}