我仅在移动版Safari和IE上收到以下错误。
TypeError: undefined is not a function
违规代码是:
if(window.location.origin.startsWith(shopAddress + "/account/login") &&
sessionStorage.getItem('loggedIn') == "true")
这在Chrome和Firefox中非常有效。任何想法为什么Safari& IE不喜欢它吗?
答案 0 :(得分:2)
您可以添加以下polyfill
if(!String.prototype.startsWith) {
String.prototype.startsWith = function(searchString, position){
return this.substr(position || 0, searchString.length) === searchString;
};
}