gpt4 book ai didi

javascript - Cordova javascript错误: has no method startsWith Android

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:04:46 26 4
gpt4 key购买 nike

我有两台设备,一台是 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;
};
}

关于javascript - Cordova javascript错误: has no method startsWith Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33106114/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com