Cordova javascript error: has no method startsWith Android
Cordova javascript error: has no method startsWith Android
我有两台设备,一台是 Lollipop,一台是 Kitekat...一台 Lollipop 没有报告任何错误,但是当我尝试我的应用程序时,我收到了这个错误:
10-13 16:56:56.126: I/chromium(6322): [INFO:CONSOLE(99)] "Uncaught
TypeError: Object ALIM. IL SOLE DI LOPARDO MARIANGELA has no
method 'startsWith'", source: file:///android_asset/www/soggetti3.html (99)
这是我的一部分 javascript:
function onDeviceReady() {
window.rancolor=ranColor();
var ricerca=localStorage.getItem('testo_ricerca');
var risultati = JSON.parse(localStorage["risultati"]);
var ricerca1=ricerca.toString();
ricerca1=ricerca1.toUpperCase();
var res_match=[];
var lll=risultati.length;
for(var r=0;r<lll;r++){
var ppp0=risultati[r][1].toString();
var ppp1=risultati[r][0].toString();
var ppp2=risultati[r][2].toString();
var ppp3=risultati[r][3].toString();
ppp0=ppp0.toUpperCase();
alert(ppp0);
alert(ricerca1);
var check=ppp0.startsWith(ricerca1);
if(check==true){
res_match=res_match.concat([[ppp1,ppp0,ppp2,ppp3]]);
}
}
var y=res_match.length;
我应该如何搜索字符串数组来搜索以其他字符串开头的字符串?
startWith函数最简单的实现方式如下所示,您可以在自己的代码中使用startsWith:
if (typeof String.prototype.startsWith != 'function') {
// see below for better implementation!
String.prototype.startsWith = function (str){
return this.indexOf(str) === 0;
};
}
我有两台设备,一台是 Lollipop,一台是 Kitekat...一台 Lollipop 没有报告任何错误,但是当我尝试我的应用程序时,我收到了这个错误:
10-13 16:56:56.126: I/chromium(6322): [INFO:CONSOLE(99)] "Uncaught
TypeError: Object ALIM. IL SOLE DI LOPARDO MARIANGELA has no
method 'startsWith'", source: file:///android_asset/www/soggetti3.html (99)
这是我的一部分 javascript:
function onDeviceReady() {
window.rancolor=ranColor();
var ricerca=localStorage.getItem('testo_ricerca');
var risultati = JSON.parse(localStorage["risultati"]);
var ricerca1=ricerca.toString();
ricerca1=ricerca1.toUpperCase();
var res_match=[];
var lll=risultati.length;
for(var r=0;r<lll;r++){
var ppp0=risultati[r][1].toString();
var ppp1=risultati[r][0].toString();
var ppp2=risultati[r][2].toString();
var ppp3=risultati[r][3].toString();
ppp0=ppp0.toUpperCase();
alert(ppp0);
alert(ricerca1);
var check=ppp0.startsWith(ricerca1);
if(check==true){
res_match=res_match.concat([[ppp1,ppp0,ppp2,ppp3]]);
}
}
var y=res_match.length;
我应该如何搜索字符串数组来搜索以其他字符串开头的字符串?
startWith函数最简单的实现方式如下所示,您可以在自己的代码中使用startsWith:
if (typeof String.prototype.startsWith != 'function') {
// see below for better implementation!
String.prototype.startsWith = function (str){
return this.indexOf(str) === 0;
};
}