收藏
回答

关于赋值问题 = 的使用

框架类型 问题类型 终端类型 微信版本 基础库版本
小程序 Bug 客户端 2.2.5 2.2.5

- 当前 Bug 的表现(可附上截图)



该问题是 在 95 到 99 有赋值问题,之后又修改了

e.detail.value 内的值,但是 也同时把   that.data.requestData 的值全部修改了,完全变为了一样的,求解是什么问题


// pages/inOffer/inOffer.js const app = getApp(); Page({ /** * 页面的初始数据 */ data: { itemTypelist: ['包裹', '文件', '防水袋'], itemTypeIndex: 0, url: '../inOffer/data/data', destination:'', remarks:'', type:'', requestData:{}, }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { console.info(options.type); if (options.type == 'reach'){ this.setData({ type: 'reach', }); } this.setData({ destination:'', }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function() { }, /** * 生命周期函数--监听页面显示 */ onShow: function() { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { }, itemTypeChange: function(e) { this.setData({ itemTypeIndex: e.detail.value }) }, destinationBt: function() { wx.navigateTo({ url: '../inOffer/destination/destination', }) }, submitSeeOffer: function(e) { var that = this; console.info(e.detail.value); that.data.requestData = e.detail.value; if (that.data.requestData.itemType == '防水袋'){ that.data.requestData.itemType = 'PAK'; } if (e.detail.value.weight.length == 0) { wx.showToast({ title: '重量不正确', duration: 2000, icon: 'none', }) return; } if (e.detail.value.destination.length == 0) { wx.showToast({ title: '目的地不能为空', duration: 2000, icon: 'none', }) return; } e.detail.value.weight = e.detail.value.weight * 1000; if (e.detail.value.itemType == '文件') { e.detail.value.itemType = 0; } else if (e.detail.value.itemType == '包裹') { e.detail.value.itemType = 1; } else if (e.detail.value.itemType == 'PAK') { e.detail.value.itemType = 2; } e.detail.value.type = 1; e.detail.value.userId = app.systemForeverPr.initialId; console.info(that.data.requestData); console.info(e.detail.value); wx.showLoading({ title: '正在处理', }); wx.request({ header: { 'Content-Type': 'application/x-www-form-urlencoded' }, url: app.systemForeverPr.requestUrl + 'nmenIn/offer', data: e.detail.value, method: 'POST', success: function(res) { console.info(res); if (res.data.result == 'Success') { that.setData({ json: res.data.list, }); } else { wx.showToast({ title: res.data.result, icon: 'none', duration: 2000 }) } }, complete: function () { wx.hideLoading(); }, }) }, gotoData: function(options) { var that = this; console.info(options.currentTarget.dataset); if (that.data.type != 'reach'){ options.currentTarget.dataset.price.remarks = encodeURIComponent(options.currentTarget.dataset.price.remarks); wx.navigateTo({ url: that.data.url + '?price=' + JSON.stringify(options.currentTarget.dataset.price), }); }else{ var pages = getCurrentPages(); var prevPage = pages[pages.length - 2]; //上一个页面 //直接调用上一个页面的setData()方法,把数据存到上一个页面中去 console.info(that.data.requestData); prevPage.setData({ 'getData.channel': options.currentTarget.dataset.price.cemskind, 'getData.pay': options.currentTarget.dataset.price.price, 'getData.country': that.data.requestData.destination, 'getData.weight': that.data.requestData.weight, 'getData.goodstype': that.data.requestData.itemType, }) wx.navigateBack(); } } })
回答关注问题邀请回答
收藏

2 个回答

  • 止戈
    止戈
    2018-10-27

    最后还是使用了  setData 才不会改变,等号还是一样

    2018-10-27
    有用
    回复
  • Hasaki
    Hasaki
    2018-10-26
    号左边只可以是一个可变的值,b显然是对的,c涉及到","运算符,他的运算规则是,从左到右,每个运算的结果传递给下一个运算,最终将最右边的运算值赋值给最前面的值,为了看得更清楚你可以把c项改成d=(d=0,e=0,9+e,e++,d+9)
    2018-10-26
    有用
    回复
登录 后发表内容