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"]     
        }
    }
  • 相关阅读:
    java 类加载与初始化
    字符串匹配
    二分查找
    一般css样式开头公共部分
    js或jquery实现图片轮播
    w3chtml页面和css书写规范
    前端学习网站
    相关学习网站
    char对比varchar
    用抽象类或者接口?
  • 原文地址:https://www.cnblogs.com/jishugaochao/p/11103551.html
Copyright © 2011-2022 走看看