From ac2467c897b59efd776b78e7790f2f8a4e89912b Mon Sep 17 00:00:00 2001 From: zhimo Date: Fri, 18 Jun 2021 11:37:54 +0800 Subject: [PATCH] Update keyword.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 支持兼容ie --- static/js/keyword.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/static/js/keyword.js b/static/js/keyword.js index 978d82e..580872b 100644 --- a/static/js/keyword.js +++ b/static/js/keyword.js @@ -28,7 +28,28 @@ $(function () { $searchLogo.on('click', function () { $searchMethods.show(); }); +/*兼容处理 低版本IE*/ +// +Array.prototype.find || (Array.prototype.find = function (predicate) { + if (this == null) { + throw new TypeError('Array.prototype.find called on null or undefined'); + } + if (typeof predicate !== 'function') { + throw new TypeError('predicate must be a function'); + } + var list = Object(this); + var length = list.length || 0; + var thisArg = arguments[1]; + var value; + for (var i = 0; i < length; i++) { + value = list[i]; + if (predicate.call(thisArg, value, i, list)) { + return value; + } + } + return null; +}) // 搜索引擎切换 $searchMethods.on('click', 'li', function () { var type = $(this).data('type'); @@ -260,4 +281,4 @@ $(function () { window.open(baseUrl.url + keyword, keyword); } } -}); \ No newline at end of file +});