This article mainly shares vue.js array update examples with you, hoping to help everyone.
Change the original array
push()
pop()
shift()
unshift()
splice()
sort()
reverse()
Does not change the original array
filter()
contat()
slice()
Example:
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 Copy after login
mounted(){ this.books.push({ //push数组方法,视图直接改变 name:'《css3实战》', author:'huiyh' }); this.books=this.books.concat([{ //concat数组方法,需更新原数组 name:'《html5实战》', author:'lala' }]) }
The above is the detailed content of vue.js array update example sharing. For more information, please follow other related articles on the PHP Chinese website!