jeecgbootvue2重新整理数组数据或者添加合并数组并遍历背景图片或者背景颜色

想要实现处理后端返回数据并处理,添加已有静态数据并遍历快捷菜单背景图

遍历数组并使用代码

需要注意:

1、静态数组的图片url需要的格式为

javascript 复制代码
require('../../assets/b.png')

2、设置遍历背景图的代码必须是:

javascript 复制代码
:style="{ 'background-image': 'url(' + item.url + ')' }"

处理数据的模块代码为

TypeScript 复制代码
getLoginfoSaveMenu() {
      getCommandsMenuForShortcut().then(response => {
        this.shortcut = response.result.shortcut
        this.shortcut.map(item => {
          this.checkedKeys.push(item.key)
        })
        this.checkeddatas = response.result.shortcut.map((item, index) => {
          return {
            color: this.appList[index % 4].color,//这个为背景颜色使用同背景图
            url: this.appimgs[index % 4].url,//为将静态图片遍历放入穿梭框内
            ...item
          }
        })
        this.targetKeys = this.checkeddatas.map(item => {
          return item.id
        })
      }).catch(error => {
        this.$message.success(error)
      })
    },

获取到的数据类型为

处理后的数据类型为

相关推荐
小河豚oO6 分钟前
LeetCode 热题 100 - 哈希 - 128
算法·leetcode·哈希算法
客卿1237 分钟前
力扣100题之128. 最长连续序列
算法·leetcode·哈希算法
T1an-17 分钟前
【力扣链表篇】206.反转链表
算法·leetcode·链表
码农开荒路1 小时前
Redis底层数据结构之字典(Dict)
java·数据结构·数据库·redis
xphjj1 小时前
树形数据模糊搜索
前端·javascript·算法
Once_day2 小时前
代码训练LeetCode(24)数组乘积
算法·leetcode
lyh13443 小时前
【Fiddler抓取手机数据包】
数据结构
int型码农4 小时前
数据结构第八章(二)-交换排序
c语言·数据结构·算法·排序算法
YKPG4 小时前
C++学习-入门到精通【14】标准库算法
c++·学习·算法
CoovallyAIHub4 小时前
AI+无人机如何守护濒危物种?YOLOv8实现95%精准识别
深度学习·算法·计算机视觉