收藏
回答

wx.request返回的报文会把数字.0取掉取整,postman返回正常

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug wx.request 工具 8.0.52 3.6.0

Postman返回:{"otherAmount":"1","rechargeMin":0.01,"rechargeMax":99999.0,"datas":[{"amount":5.0,"actualAmount":5.0,"sendAmount":0.0,"discAmount":0.0,"minDiscRate":1,"payable":5.0,"ruleBillNo":"","ruleDescription":"","incentiveList":[]},{"amount":10.0,"actualAmount":10.0,"sendAmount":0.0,"discAmount":0.0,"minDiscRate":1,"payable":10.0,"ruleBillNo":"","ruleDescription":"","incentiveList":[]},{"amount":15.0,"actualAmount":15.0,"sendAmount":0.0,"discAmount":0.0,"minDiscRate":1,"payable":15.0,"ruleBillNo":"","ruleDescription":"","incentiveList":[]}],"rechargeFree":null,"success":true,"serviceStatus":"000","serviceDescription":"服务执行成功"}

微信开发工具返回:{"otherAmount":"1","rechargeMin":0.01,"rechargeMax":99999,"datas":[{"amount":5,"actualAmount":5,"sendAmount":0,"discAmount":0,"minDiscRate":1,"payable":5,"ruleBillNo":"","ruleDescription":"","incentiveList":[]},{"amount":10,"actualAmount":10,"sendAmount":0,"discAmount":0,"minDiscRate":1,"payable":10,"ruleBillNo":"","ruleDescription":"","incentiveList":[]},{"amount":15,"actualAmount":15,"sendAmount":0,"discAmount":0,"minDiscRate":1,"payable":15,"ruleBillNo":"","ruleDescription":"","incentiveList":[]}],"rechargeFree":null,"success":true,"serviceStatus":"000","serviceDescription":"服务执行成功"}


回答关注问题邀请回答
收藏

1 个回答

  • H1HAO 🇨🇳
    H1HAO 🇨🇳
    10-10

    这个是这样的实际不影响你使用,你可以直接使用.toFixed(2)

    js:
    var num = 1
    num = num.toFixed( 2 )
    console.log(num)//1.00
    
    var num = 1.0
    num = num.toFixed( 2 )
    console.log(num)//1.00
    
    var num = 1.1
    num = num.toFixed( 2 )
    console.log(num)//1.10
    var num = 0.01
    num = num.toFixed( 2 )
    console.log(num)//0.01
    
    页面:
    <view>{{(1).toFixed( 2 )}}</view>//1.00
    
    <view>{{(1.0).toFixed( 2 )}}</view>//1.00
    
    <view>{{(0.1).toFixed( 2 )}}</view>//0.10
    
    <view>{{(0.01).toFixed( 2 )}}</view>//0.01
    
    10-10
    有用
    回复
登录 后发表内容