1:在data定义了一个数组
yinhuanlist: [{ fangan: "测试编辑311", id: "51", img:["upload/20191204/rt8uymq7igpmj4g.jpg", "upload/20191204/mh6dng20h1zc599.jpg", "upload/20191204/l35k4fs11yoyjt3.jpg", "upload/20191204/q5l9uzjv2lgjc8r.jpg", "upload/20191204/nk4duu7bkt4k3wa.jpg", "upload/20191204/fmgiamnf6bmrh5m.jpg"], isjiejue: "未解决", jl_openid: "otmx45ALDrzVholKBxuZkHXTpkn4", quyu: "测试编辑2111", wenti: "测试编辑111" }], edit: {},//二次编辑需要内容 laoimgpath:'', uploaderList2:'', |
2:在按钮事件中,传递该数组变量给新的变量 edit
this.setData({ isedit: true, yinhuanid: e.currentTarget.dataset.id, //隐患id edit: this.data.yinhuanlist[e.currentTarget.dataset.arrid] //把要编辑的隐患赋值到新对象,弹窗的时候调用 }) |
3:调用wx.chooseImage 选择图片
wx.chooseImage({ count: 9, // 默认9 sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 sourceType: ['album'], // 可以指定来源是相册还是相机,默认二者都有 success: function (res) { console.log('选择返回', res) // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片 let tempFilePaths = res.tempFilePaths; that.data.laoimgpath = that.data.edit.img; //老的隐患图片的路径先保存出来,因为在表单提交到后台还需要他的 that.data.uploaderList2 = tempFilePaths; //修改新文件的array 提交到后台要上传的,在这里赋值表单中提交 that.data.edit.img = that.data.edit.img.concat(tempFilePaths) //把新的和老的合并显示到前台 console.log('edit', that.data.edit) that.setData({ edit: that.data.edit,//更形到前台 //uploaderNum: that.data.edit.img.length, isdel: false //不允许删除图片 }) console.log('现在图片后yinhuan2', that.data.yinhuanlist) } }) |
第三步里面完全没有操作 this.data.yinhuanlist
当图片选择完毕后,会自动修改this.data.yinhuanlist的值,此时在打印this.data.yinhuanlist的值会发现他已经7个了...
由此判断wx.chooseImage 选择图片api有个bug,可能会导致有引用关系的变量自动修改值
我已经生成了代码片断,望官方尽快处理下,怎么做都不对,早晨搞到晚上,才发现问题出在微信这里...
我的联系电话18949371668 如果有需要可以电话我
