已上线小程序,通过input输入修改数据库数据时每次输入2.28数据库后台会更新成2.27999999999999999997,不知什么原因?
<view class="input_box">
<label>请输入单独购买价格:</label>
<input type='text' name="mprice" placeholder="{{item.mprice/100}}" value="{{item.mprice/100}}" />
</view>
wx.showModal({ content: '是否更新产品?' , success: function (res) { if (res.confirm) { wx.cloud.callFunction({ name: 'updateproduct' , data: { type: 'updateproducts' , data: { id2: e.detail.target.dataset.id, endTime2: e.detail.value.endTime, gprice2: e.detail.value.gprice * 100, groupSize2: e.detail.value.groupSize, maxNum2: e.detail.value.maxNum, mprice2: e.detail.value.mprice * 100, unit2: e.detail.value.unit, name2: e.detail.value.name, sort2: Number(e.detail.value.sort), serviceNote2: e.detail.value.servicenote, cid2: Number(self.data.cid), sale_flag: sale_flag } } }) .then(res => { wx.showToast({ title: '更新产品成功' , icon: 'success' }) |
以下为云函数代码
return await goodsorderCollection.doc(id2) .update({ data: { endTime: endTime2, gprice: gprice2, groupSize: groupSize2, maxNum: maxNum2, mprice: mprice2, unit: unit2, name: name2, sort: sort2, serviceNote: serviceNote2, cid: cid2, sale_flag: sale_flag, } }) } catch (e) { console.error(e) } |
浮点数
这不是bug~~~~