javascript Internet Explorer 11:对象不支持属性或方法“isInteger”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31720269/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Internet Explorer 11 : Object doesn't support property or method 'isInteger'
提问by Stefan
i have this error in internet explorer console ' Object doesn't support property or method 'isInteger' ' how can i resolve it ?
我在 Internet Explorer 控制台中遇到此错误“对象不支持属性或方法“isInteger””,我该如何解决?
code:
代码:
function verificaNota(nota){
if (nota.length>0){
var arr = [];
if( nota.indexOf(".") != -1 ){
return ferificareArrayNote(nota.split('.'));
}else if( nota.indexOf(",") != -1 ){
ferificareArrayNote(nota.split(','));
}else if( nota.length<=2 && Number.isInteger(Number(nota)) && Number(nota)<=10 && Number(nota) > 0){
return true;
}else {
return false;
}
}
return true;
}
And yes, i pass it a number not char;
是的,我传递了一个数字而不是字符;
回答by Jaromanda X
As stated by @Andreas, Number.isNumber is part of ES6 so not supported by IE11
正如@Andreas 所述,Number.isNumber 是 ES6 的一部分,因此不受 IE11 支持
You can add the following polyfill to you javasript
您可以将以下 polyfill 添加到您的 javasript
Number.isInteger = Number.isInteger || function(value) {
return typeof value === "number" &&
isFinite(value) &&
Math.floor(value) === value;
};
source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger
来源:https: //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger