Internet Explorer 11: 对象不支持属性或方法'isInteger'

19
我在Internet Explorer控制台中遇到了这个错误:“对象不支持属性或方法'isInteger'”,我该如何解决?
代码:
    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;
    }

是的,我传递的是数字而不是字符;

2
.isNumber 是 ES6 的一部分,不支持 IE11:浏览器兼容性 - Andreas
与此同时,请使用 polyfill - https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger - Jaromanda X
你也可以使用 Lodash 的 isInteger() 来确保浏览器支持。 - Robin Métral
1个回答

51

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接