vue.js 数组更新
改变原始数组
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" }]) }
声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇:没有了
- 下一篇: 千位分隔符