[英]javascript findIndex issue with IE
我刚刚完成了一个小表格,发现我使用findIndex的方式与IE不兼容。
这是一个问题的例子。
var people = [
{name:"Mike", age:"25"},
{name:"Bill", age:"35"},
{name:"Terry", age:"44"}
];
console.log(people.findIndex(x => x.name=="Bill" ));
什么是解决IE问题的最快方法?
找到对浏览器的索引支持
Chrome 45.0 and above: Supports
Firefox 25.0 and above: Supports
Internet Explorer: No support
Microsoft Edge: Supports
Opera: Supports
Safari 7.1 and above: Supports
所以你需要修改类似于下面的代码,以便在所有浏览器中工作。
var index;
for(var i=0;i<people.length;i++){
if(people[i].name == 'billi'){
index = i
}
}
这对IE来说是最好的
people.findIndex(function(x){ x.name=="Bill" }));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.