两个数值比较,结果发现输入11的时候大于100等于true?
发布于 5 年前 作者 fang22 13984 次浏览 来自 官方Issues

下面是js代码:

cashmoney: function (e) {

var that = this;

var amounts = that.data.amounts;

var money = that.data.money;

console.log(that.data.amounts + "============================" + that.data.money)

console.log(that.data.amounts>that.data.money)

if (!(/^$|^([0-9]{1}|[1-9]+\d*)(.{0,1}\d{1,2})?$/.test(that.data.amounts)) || that.data.amounts.substring(0, 1) == 0 || amounts > money) {

wx.showToast({

icon: "none",

title: '请输入合理的金额!',

duration:1500

})

}else{

console.log(app.globalData.weixinAccount+"============================"+app.globalData.zhifubaoAccount)

}

}

这是输入框:

<view class="cash-money">

<input type="digit" placeholder="请输入要提现的金额" bindinput="moneyinput" value="{{amounts}}"></input>

</view>


这是输出结果,

3 回复

猜测是字符串和数字比对的问题。

注意颜色

再来一张图

--↓↓👍点赞是回答的动力哦

你那是字符串吧

回到顶部