Heim > Fragen und Antworten > Hauptteil
Das Beispiel ist a="2,322,222",b='1,211,21', wie man eine Winkelsubtraktion durchführt
怪我咯2017-05-16 13:46:20
function(a, b) {
a = a.replace(',', '');
b = b.replace(',', '');
return (+a - +b).toFixed(2);
}
过去多啦不再A梦2017-05-16 13:46:20
使用split(',')按找‘,’分成多个数组,根据长度判断,比如a就是 21000 b就是 11000,更多逗号,就是根据长度判断,长度为3就是下标为0的时候10001000 考虑 Math.pow(10,n * 3) 方法,装换成数字进行相减。可以试试