使用...修改原有json中的某一項提交

使用…修改原有json中的某一項提交

// 修改購房意向
  filterIntention:function(e){
    
    let that = this;
    //獲取到需要提交的意向ID
    that.setData({
      intention: that.data.client.intention_item[e.currentTarget.dataset.index].id
    })
    //修改頁面上的選中狀態
    let obj = {
      ...that.data.client,
      intention_item: that.data.client.intention_item.map((item, index) => {
        item.checked = 0;
        if (index == e.currentTarget.dataset.index) {
          item.checked = 1;
        }
        return item;
      })
    }
    //賦值頁面
    that.setData({
      client: obj
    })
  },
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章