0
点赞
收藏
分享

微信扫一扫

2024深圳杯数学建模竞赛A题(东三省数学建模竞赛A题):建立火箭残骸音爆多源定位模型

进击的铁雾 2024-05-02 阅读 10

1.数组的indexOf方法

一般此方法用来判断数组中是否包含某个元素,即为循环数据中删除按钮使用。

let list = ['1','2','3','4'];
console.log(list.indexOf('2')) //如果存在返回会返回索引值 1
console.log(list.indexOf('6')) //如果不存在返回会返回 -1
let index = list.indexOf('2')
if(index !== -1){
   list.splice(index, 1);
}

2.数组的map方法

返回一个新的数组 新数组中的元素是经过map函数内部代码块处理过的数据
let list = [1,2,3,4]
let arry = list.map(item=>{
	return item + 1
})
console.log(arry);

3.数组的forEach方法

数组遍历拿到每一项

   data() {
     return {
        list:[
          {
            id:1,
            name:'张三',
            isshow:false
          },
          {
            id:2,
            name:'李斯特',
            isshow:true

          },
          {
            id:3,
            name:'王麻子',
            isshow:false

          }
        ]
     }
   },
   mounted() {
     this.list.forEach(item=>{
      console.log(item)
     })
   },

4.数组的filter方法

 拿到符合条件的某一项

    const list = [
      {
        id: 1,
        name: '张三',
        isshow: false
      },
      {
        id: 2,
        name: '李斯特',
        isshow: true

      },
      {
        id: 3,
        name: '王麻子',
        isshow: false

      }
    ]
    const islist = list.filter(item => {
      return item.isshow
    })
    console.log(islist);
举报

相关推荐

0 条评论