parseInt固定值 [英] parseInt fixing the value

查看:240
本文介绍了parseInt固定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里我对逗号很感兴趣.

Here I have a value with commas.

Ex:- var abc ="10,10.12";

如果我使用 var x = parseInt(abc);

它返回 10

预期输出为 10,10.12

就像我在JSP中使用 ng-value ="UpdatedPropuesta.VALOR_CUOTA | number:2" 一样.

as I have used ng-value="UpdatedPropuesta.VALOR_CUOTA | number:2" in JSP.

推荐答案

如果您要在字符串中使用数字数组,请尝试使用此方法,

If you want an array of numbers out of the string then try this,

const input = "10,10.12";
var output = input.split(",");
output = output.map(i => Number(i));
console.log(output);

这篇关于parseInt固定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆