最近搜索

小程序 修改 对象 里面的 某个属性 某个节点

浏览:827
管理员 2020-08-05 00:08

修改 数组  删除数据  修改某个数组 index


修改对象   修改对象 属性




小程序  修改 对象 里面的   某个属性  某个节点

              that.setData({
                'task_obj.state':1
              })



修改数组某个节点的数据。


    console.log(e.detail);//e.detail.client  e.detail.phone 
    const { index, client, phone, address, remark } = e.detail;
    this.setData({
      [`xiaoshouHeadList[${index}].client`]: client,
      [`xiaoshouHeadList[${index}].phone`]: phone,
      [`xiaoshouHeadList[${index}].address`]: address,
      [`xiaoshouHeadList[${index}].remark`]: remark,
      edit_show: false
    });
    
     const { index, client, phone, address, remark } = e.detail; 等价于
    const index = e.detail.index;
    const  client = e.detail.client;
     const phone = e.detail.phone;
     const address = e.detail.address;
     const remark = e.detail.remark;


小程序  操作 数组  array 删除某个下标 的数据。


  del_content_img(e) {
        console.log(e.currentTarget.dataset.index);
        var index = e.currentTarget.dataset.index;
        // 创建一个新数组,不包含要删除的元素  
        var new_arr = this.data.content_img_list.filter((img, i) => i !== index);
        // 更新数据  
        this.setData({
            content_img_list: new_arr
        });
    },


联系站长

站长微信:xiaomao0055

站长QQ:14496453