重新写一下编辑方法,注意修改cid和yid实际为修改note:

editGoods(id, key, value) {
  let goods = this.goodsList.find(item => item.id === id);
  if (goods) {
    if (key === 'note') {
      let noteObj = goods.note ? JSON.parse(goods.note) : {};
      noteObj.cid = value;
      noteObj.yid = value;
      goods.note = JSON.stringify(noteObj);
    } else {
      goods[key] = value;
    }
  }
},

其中,当key为'note'时,我们先判断原先的note是否存在,如果存在则将其转换为对象,并修改cid和yid属性的值;若不存在,则新建一个空对象,并设置cid和yid属性的值。最后,将修改后的note转换为字符串,保存到商品对象中。

td itemgid td						 td contenteditable=true input=editGoodsitemid name $eventtargetinnerText itemname td						 td contenteditable=true input=editGoodsitemid money $eventtargetinnerText itemmoney td

原文地址: https://www.cveoy.top/t/topic/bdLA 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录