[英]Nextjs 'endsWith' polyfill problem on edge and ie11
由於Object doesn't support property or method 'endsWith'
錯誤,我的站點中斷並無法運行。 我試過用import 'core-js/features/string/ends-with'
或
if (!String.prototype.endsWith) {
String.prototype.endsWith = function (search, this_len) {
if (this_len === undefined || this_len > this.length) {
this_len = this.length
}
return this.substring(this_len - search.length, this_len) === search
}
}
我已經在我的自定義_app
文件中做到了這一點,但它在 edge 和 ie11 中仍然失敗。 我錯過了什么?
編輯:從https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith#Browser_compatibility endsWith
來看,Edge 應該支持
嘗試將其添加到您的代碼中。
String.prototype.endsWith = function(pattern) {
var d = this.length - pattern.length;
return d >= 0 && this.lastIndexOf(pattern) === d;
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.