Today is plagued by a problem, there is a page in the browser (whether mobile phone or PC) on the good run, and through the webview there are problems, there are two worthy of calculation always error. And then, by alert, the value is displayed, and the results of the calculation on the browser are much worse, which is a positive number, but it becomes negative. Carefully compared to the discovery, some of the numbers were erased, and these numbers were transformed by parseint from strings. The only difference between the erased values and the other normal numbers is that they all start with 0, such as "04903", while the other values are "90874". As a result, it is obvious that the webview-supported JavaScript parseint turns the string beginning with 0 to 0. The problem found the solution is easier, write a str2int method, to replace the parseint on it.
Str2int:function (str) {
str = str.replace (/^0+/g, ');
if (Str.length = = 0) {return
0;
}
return parseint (str);