数组得相关操作

数组得过滤
在这里插入图片描述
选择对应得用户到数组里面

      this.selectData.push(row);
      //数组对象去重 es6 https://blog.csdn.net/love_life_forever/article/details/107967487
      this.selectData = this.selectData.filter((element, index, self) => {
        return self.findIndex((x) => x.nickName === element.nickName) === index;
      });

删除多选择得对应项目

      arr.push(row.userId);
      this.selectData = this.selectData.filter(
        (item) => !arr.includes(item.userId)
      );xml


数组得遍历加条件
在这里插入图片描述

     this.eventXZ.forEach((value, index, array) => {
          if (value.dictLabel !== "变更") {
            this.arrNew.push(value);
          }
        });

数组v-for遍历

                v-for="item in roleOptions"
                :key="item.roleId"
                :label="item.roleName"
                :value="item.roleCode"
                :disabled="item.status == 1"

多个数组合并一个数组

        this.form.annex = [...this.Universal, ...this.construction, ...this.performance]

JSON.stringify() 与 JSON.parse 操作

JSON.stringify() 从一个对象中解析出字符串
JSON.stringify({“a”:“1”,“b”:“2”})
结果是:“{“a”:“1”,“b”:“2”}”

JSON.parse()从一个字符串中解析出JSON对象

var str = ‘{“a”:“1”,“b”:“2”}’;
JSON.parse(str);
结果是:Object{a:“1”,b:“2”}

array.reduce

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值