抱着猫睡觉的鱼_ 2021-10-25 16:03 采纳率: 51.7%
浏览 33
已结题

表格插入图片没有及时更新dom问题

element-----------打印的数据

img

想把每一条数据的specItems的image赋值给specItem,但是现在页面上的dom没有更新,需要再次点击,求详细解释,这里的$set应该怎么写

 
 
// 表格插入图片
    createImgsObj() { 
       this.$forceUpdate();
      let imgsObj = {}
      let tableCategoryList = this.tableCategoryList
      // 循环规格值的数组
      for (let index = 0; index < tableCategoryList.length; index++) {
        const element = tableCategoryList[index]
        console.log(element,'element-----------');
        if (element.specItems.length > 0) {
          let specItems = element.specItems
          console.log(specItems,'specitems===========')
          for (let i = 0; i < specItems.length; i++) {
            const tempArray = specItems[i]
            console.log(tempArray,'jjj')
            console.log(tempArray.specItem,'k==================v')
            // imgsObj[tempArray.specItem] = tempArray.image; 
  // imgsObj[tempArray.specItem] = tempArray.image; 把tempArray里面的imgage给到this.imgsObj tempArray里面的specItem
            this.$set(imgsObj,'specItem',tempArray.image) 
            // imgsObj[tempArray.specItem] = 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg'

  • 写回答

3条回答 默认 最新

  • 普通网友 2021-10-25 16:11
    关注

    你要说清楚,你使用的js库是什么?
    不然,不好判断$.set里面做什么操作?

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 11月5日
  • 创建了问题 10月25日

悬赏问题

  • ¥15 微软硬件驱动认证账号申请
  • ¥15 有人知道怎么在R语言里下载Git上的miceco这个包吗
  • ¥15 GPT写作提示指令词
  • ¥20 如何在cst中建立这种螺旋扇叶结构
  • ¥20 根据动态演化博弈支付矩阵完成复制动态方程求解和演化相图分析等
  • ¥20 关于DAC输出1.000V对分辨率和精度的要求
  • ¥20 想写一个文件管理器,加载全部子文件夹后,要一级一级返回
  • ¥15 华为超融合部署环境下RedHat虚拟机分区扩容问题
  • ¥15 哪位能做百度地图导航触点播报?
  • ¥15 请问GPT语言模型怎么训练?