Javascript 对象1011没有方法';从'开始;
我正在尝试根据所选产品对产品详细信息对象进行分类Javascript 对象1011没有方法';从'开始;,javascript,angularjs,ionic-framework,Javascript,Angularjs,Ionic Framework,我正在尝试根据所选产品对产品详细信息对象进行分类 if (prodCode.startsWith("1") || prodCode.startsWith("4")) { ProductDetails = obj.MachineDetails; } else if (prodCode.startsWith("6")) { if (prodCode.charAt(3) == '3' || prodCode.charAt(3) == '4') { ProductDeta
if (prodCode.startsWith("1") || prodCode.startsWith("4")) {
ProductDetails = obj.MachineDetails;
}
else if (prodCode.startsWith("6")) {
if (prodCode.charAt(3) == '3' || prodCode.charAt(3) == '4') {
ProductDetails = obj.BoxDetails;
}
else {
ProductDetails = obj.SomeDetails;
}
}
else if (prodCode.startsWith("2") || prodCode.startsWith("3")) {
ProductDetails = obj.SomeOtherDetails;
}
它在安卓4.4上运行良好,但在安卓4.4中出现错误:
对象1011没有方法“startsWith”
1011
是我的产品代码
有人知道为什么会这样吗?在Android版本之间,javascript引擎并不总是相同的,最新的功能也不总是可用的 我遇到了同样的问题:在调用startsWith之前,必须添加一个多边形填充
检查Mozilla页面上的polyfill部分:根据
字符串。prototype.startsWith
可能不会在android 4.4中实现。您可以使用console.log(typeof String.prototype.startsWith==“function”)检查这一点。
您可以共享console.log(String.prototype.startsWith)的输出吗代码>和console.log(产品代码类型)代码>?尝试使用Polyfill启动