简体   繁体   English

Cordova javascript错误:没有方法启动Android

[英]Cordova javascript error: has no method startsWith Android

i've got two devices one with Lollipop and one with Kitekat... the one with Lollipop does not report any error but when i try my application i obtain this error: 我有两个设备一个与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)

here is a part of my javascript: 这是我的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;

how should i search an array of strings searching the strings that begin with some other string? 我应该如何搜索一个字符串数组,搜索以其他字符串开头的字符串?

The easiest way to implement the startWith function is shown below, then you can use startsWith in your code: 实现startWith函数的最简单方法如下所示,然后您可以在代码中使用startsWith:

if (typeof String.prototype.startsWith != 'function') {
  // see below for better implementation!
  String.prototype.startsWith = function (str){
    return this.indexOf(str) === 0;
  };
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM