My site breaks and fails running because of the Object doesn't support property or method 'endsWith'
error. I've tried polyfilling it with import 'core-js/features/string/ends-with'
or
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
}
}
I've done that in my custom _app
file but it still fails in edge and ie11. What am I missing?
Edit: Judging by the https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith#Browser_compatibility endsWith
should be supported in Edge
Try to add this to your code.
String.prototype.endsWith = function(pattern) {
var d = this.length - pattern.length;
return d >= 0 && this.lastIndexOf(pattern) === d;
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.