0

我尝试使用离子无限加载更多项目,

doRefresh(event) {
    console.log('Begin async operation');  
    setTimeout(() => {
      this.nextpage()
      console.log("test")
      event.target.complete();
    
    }, 2000);
}
nextpage(){   
    this.datanum = this.datanum+5;
    this.sqliteDB.getAttractionsbycondition(this.sql,this.datanum).then(res => {
      this.alldata_new = res   
      this.alldata_new.forEach(element => {
        this.geocoder.geocode({ 'address': element.Address },  (results, status)  => { //先找到當地的經緯度 
          let pos;
          if (status == google.maps.GeocoderStatus.OK) {
              pos = {                                         //目標經緯度
                lat: results[0].geometry.location.lat(),
                lng: results[0].geometry.location.lng()
              };    
         

              if(google.maps.geometry.spherical.computeDistanceBetween(new google.maps.LatLng(pos.lat, pos.lng), new google.maps.LatLng(this.exampleLat,this.exampleLng))>=1000){
    
                 this.distance = google.maps.geometry.spherical.computeDistanceBetween(new google.maps.LatLng(pos.lat, pos.lng), new google.maps.LatLng(this.exampleLat,this.exampleLng))/1000;
                 this.distance = Math.round(this.distance);
                 if(this.distance>this.data.distance){
                    console.log("too far");
                    this.alldata_new.splice(this.alldata_new.indexOf(element),1);
                 } 
                 this.distance = this.distance +"kilometer";
                 element.distance = this.distance;
                 
               }else{
                this.distance = google.maps.geometry.spherical.computeDistanceBetween(new google.maps.LatLng(pos.lat, pos.lng), new google.maps.LatLng(this.exampleLat,this.exampleLng));
                this.distance = Math.round(this.distance);
                if(this.distance/1000>this.data.distance){
                  console.log("too far");
                  this.alldata_new.splice(this.alldata_new.indexOf(element),1);
               } 
                this.distance = this.distance +"meter";
                element.distance = this.distance;
              }
               // 四捨五入
              // });                
          }  
          else{
            element.Aname = "failure";
          }   
        });
      }); 
      
    })
    
    
    console.log(this.alldata+"hello ")     
  }

这是结果图片,问题是它确实工作并加载了更多项目,但我希望它们显示的信息消失了,但我确实检查了 console.log 并且新加载的项目确实推送到我的数据中,所以我想知道什么可以是问题吗? 在此处输入图像描述

4

0 回答 0