問題描述:
表格內(nèi)數(shù)據(jù)
需求:修改對應(yīng)的數(shù)據(jù)項的時候,也需要把當(dāng)前修改的數(shù)據(jù)項直接的更新到視圖中!
修改數(shù)據(jù)選項的時候:
image.png
因為修改的是整體的一個實體的數(shù)據(jù)項:
所在再更新列表數(shù)據(jù)的時候是直接的進行整體值選項的賦值更新代碼
copy_currgoodsInfoList:是更新編輯更新后的值
goodsInfoList:是列表數(shù)據(jù)
currgoodsInfoList_index:當(dāng)前需要修改數(shù)據(jù)項的列表索引值
this.goodsInfoList[this.currgoodsInfoList_index] = this.copy_currgoodsInfoList
關(guān)于VUE響應(yīng)式的原理,其實之前也有提到過,但是實際在遇到新的處理數(shù)據(jù)方式的還是還是遇到了無法刷新視圖的。
按搜索處理問題的方式,以下的這種方法,雖然刷新了,且視圖也有更新了,但是對于的數(shù)據(jù)列表頁有問題了,應(yīng)該是什么地方設(shè)置有問題。
his.goodsInfoList.splice(this.goodsInfoList[this.currgoodsInfoList_index], this.currgoodsInfoList_index, this.copy_currgoodsInfoList)
最終正確的刷新的方式:
that.$set(that.goodsInfoList, that.currgoodsInfoList_index, that.copy_currgoodsInfoList)