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)
      })
    },

获取到的数据类型为

处理后的数据类型为

相关推荐
smj2302_7968265215 分钟前
解决leetcode第3768题.固定长度子数组中的最小逆序对数目
python·算法·leetcode
cynicme36 分钟前
力扣3531——统计被覆盖的建筑
算法·leetcode
core5121 小时前
深度解析DeepSeek-R1中GRPO强化学习算法
人工智能·算法·机器学习·deepseek·grpo
mit6.8241 小时前
计数if|
算法
a伊雪2 小时前
c++ 引用参数
c++·算法
Data_agent2 小时前
1688获得1688店铺列表API,python请求示例
开发语言·python·算法
2301_764441333 小时前
使用python构建的应急物资代储博弈模型
开发语言·python·算法
小熳芋3 小时前
验证二叉搜索树- python-递归&上下界约束
数据结构
hetao17338373 小时前
2025-12-11 hetao1733837的刷题笔记
c++·笔记·算法
Xの哲學3 小时前
Linux电源管理深度剖析
linux·服务器·算法·架构·边缘计算