新增 `Array.indexof()` 在 ie8 下的兼容

pull/1363/head
贤心 2023-09-01 17:40:10 +08:00
parent 9024d2e496
commit 352cbe2613
1 changed files with 15 additions and 0 deletions

View File

@ -27,6 +27,21 @@
that.push(elem[index]);
});
};
/*
* API 兼容
*/
Array.prototype.indexOf = Array.prototype.indexOf || function(searchElement, fromIndex) {
var rst = -1;
fromIndex = fromIndex || 0;
layui.each(this, function(index, val){
if (searchElement === val && index >= fromIndex) {
rst = index;
return !0;
}
});
return rst;
};
/*
lay 对象操作