当前位置:网站首页>js 常用方法
js 常用方法
2022-08-09 00:20:00 【wwf1225】
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('请先开启模块开关,再勾选赋能选项!')
}
},
边栏推荐
猜你喜欢
随机推荐
一道dp的三次优化(时间+空间)
2021ccpc网络选拔赛
Mysql Workbench导出sql文件出错:Error executing task: ‘ascii‘ codec can‘t decode byte 0xd0 in position 26:
透明度测试-AlphaTest
STM32的HAL库初体会
线性复杂度优化 / 离散化
对js基础知识的一些理解
2018年蓝桥杯省赛本科B组-全球变暖(水漫金山)
VsCode configures your favorite fonts and backgrounds. Mom no longer worries about my boring code writing.
进阶指南图论篇
MySQL5.7设置MySQL/MariaDB 数据库默认编码为utf8mb4
神经网络基本原理
小程序textarea完美填坑
在子组件中使用echart视图不刷新的问题
XShell用命令行打包jar包(详细步骤)
Canvas绘图基础知识
求按位或的最小生成树
对纹理进行uv坐标偏移
安装wcf框架
求所有子串的最大值之和