js 常用方法

39 篇文章 1 订阅

1.push 之前一定要清空,改变数组键值名字

this.checkListPC = []

this.checkboxList.forEach((it) => {

this.checkListPC.push({

nameA: it.display_flagpc,

nameB: it.module_data_id,

nameC: it.module_data_name,

})

})

2.前端过滤搜索

// 搜索

search() {

if (this.input === '') {

this.tableData = this.tableFilder

} else {

this.tableData = this.tableData.filter((it) => {

return it.name.indexOf(this.input) > -1

})

}

this.guanliTotal = this.tableData.length

},

3.动态style 用函数返回

<div

          class="main"

          :style="{

            background: `linear-gradient(to right,${setbgc(index)},${setBto(

              index

            )})`,

            width: setWidth(data[0].data, item.data),

          }"

        ></div>

color: [

        'rgba(241,149,32,1)',

        'rgba(7,246,255,1)',

        'rgba(249,213,137,1)',

        'rgba(4,198,120,1)',

        'rgba(172,108,224,1)',

        'rgba(255,137,137,1)',

        'rgba(25,153,213,1)',

        'rgba(115,160,250,1)',

        'rgba(47,255,254,1)',

        'rgba(56,154,255,1)',

      ],

      colorBottom: [

        'rgba(241,149,32,0.2)',

        'rgba(7,246,255,0.2)',

        'rgba(249,213,137,0.2)',

        'rgba(4,198,120,0.2)',

        'rgba(172,108,224,0.2)',

        'rgba(255,137,137,0.2)',

        'rgba(25,153,213,0.2)',

        'rgba(115,160,250,0.2)',

        'rgba(47,255,254,0.2)',

        'rgba(56,154,255,0.2)',

      ],

setbgc(item) {

      return this.color[item]

    },

    setBto(item) {

      return this.colorBottom[item]

    },

    setfontColor(item) {

      return this.color[item]

    },

4.删除过滤符合条件的数据

 let arrData = data.data

          arrData.forEach((v,i)=> {

            if(v.module_data_id == '受理和办结量今日' || v.module_data_id == 'cpsxqx') {

              arrData.splice(i,1)

            }

          })

5. async  await

 async funeng() {

      if (this.checkboxList.display_flag) {

        if (this.showIndex == 0) {

          await updateModuleDataListDisplayPC(this.checkListPC).then((res) => {

            this.dialogVisible = false

            if (res.code === 200) {

              this.$message({

                message: res.message || '操作成功',

                type: 'success',

              })

            }

          })

        } else {

          await updateModuleDataListDisplayMB(this.checkListMB).then((res) => {

            this.dialogVisible = false

            if (res.code === 200) {

              this.$message({

                message: res.message || '操作成功',

                type: 'success',

              })

            }

          })

        }

        await this.getApiData()

      } else {

        this.dialogVisible = false

        this.$message.warning('请先开启模块开关,再勾选赋能选项!')

      }

    },

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值