我在 if 条件下使用变量时遇到问题。我有三个变量,其中一个是字符串类型,另外两个在 Json 中。这里 settings.DecimalDigits 的值为 2 或大于 2 的任何值。
var controlValue = integer + '.' + mantissa;
controlValue = parseFloat(controlValue).toFixed(settings.DecimalDigits);
整数和尾数将具有某个值,该值作为字符串存储在 controlValue 中。controlValue然后在 IF 条件下与其他两个变量(settings.MaxValue 和 settings.MinValue)进行比较,但它没有通过条件,因为它的类型是字符串类型
if (controlValue > settings.MaxValue)
controlValue = settings.MaxValue;
if (controlValue < settings.MinValue)
controlValue = settings.MinValue;
在我的解析中,所有三个变量都将具有三个浮点类型的值
controlValue = 123.23 或 123.00
settings.MaxValue = 99.99
settings.MinValue = -99.99
请帮助解析通过IF 条件