zoukankan      html  css  js  c++  java
  • Vue push() pop() shift() unshift() splice() sort() reverse()

    参考:https://www.cnblogs.com/ifieer/p/9926533.html

    data() {
        return {      
          arrayList:['1', '2', '3', '4', '5', '6', '7', '8', '9']
        };
      },
     methods: {
        init() {      
          console.log('init:', this.arrayList); //["1", "2", "3", "4", "5", "6", "7", "8", "9"]
          this.arrayList.push('10');
          console.log('push:', this.arrayList);//["1", "2", "3", "4", "5", "6", "7", "8", "9","10"]
          this.arrayList.unshift('0');
          console.log('unshift:', this.arrayList);//["0","1", "2", "3", "4", "5", "6", "7", "8", "9","10"]
          this.arrayList.pop();
          console.log('pop:', this.arrayList);//["0","1", "2", "3", "4", "5", "6", "7", "8", "9"]
          this.arrayList.shift();
          console.log('shift:', this.arrayList);//[1", "2", "3", "4", "5", "6", "7", "8", "9"]
          this.arrayList.splice(0, 1);
          console.log('splice:', this.arrayList);//["2", "3", "4", "5", "6", "7", "8", "9"]
          this.arrayList=this.arrayList.reverse();
          console.log('reverse:', this.arrayList);//["9", "8", "7", "6", "5", "4", "3", "2"]
          this.arrayList=this.arrayList.sort();
          console.log('sort:', this.arrayList);//["2", "3", "4", "5", "6", "7", "8", "9"]
          this.arrayList=this.arrayList.filter(item=>item!=='2');
          console.log('filter', this.arrayList);//["3", "4", "5", "6", "7", "8", "9"]     
        }
    }
  • 相关阅读:
    Linux 常用命令
    Oracle DG 三种模式(转)
    S5PV2210
    Timer wheel etc.
    SCM etc.
    负载均衡 IO etc.
    Remoting,OData Snippet Compiler等
    displaytag 动态列实现
    <display:column>属性解释
    <display:table>属性解释
  • 原文地址:https://www.cnblogs.com/jishugaochao/p/11103551.html
Copyright © 2011-2022 走看看