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

表格插入图片没有及时更新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;
            this.$set(imgsObj,'specItem',tempArray.image) 
            // imgsObj[tempArray.specItem] = 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg'
  • 写回答

4条回答 默认 最新

报告相同问题?

问题事件

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