首页 > 解决方案 > 加载资源失败:服务器响应状态为 404 (cordova)

问题描述

在此处输入图像描述

我不知道会发生什么,但离子无法加载科尔多瓦和科尔多瓦打印是写在代码中的,我该如何修复它

标签: cordovaionic-frameworkindexingscripting

解决方案


在此处输入图像描述

我的主页ts

import { Component } from '@angular/core';
import {Geolocation} from '@ionic-native/geolocation/ngx';
import { GoogleMap, GoogleMapsEvent, LatLng } from '@ionic-native/google-maps';
import{Platform,NavController} from '@ionic/angular'


declare var google:any;


@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss'], 
})
export class HomePage {
  map : any;
  markers: any;
  

  estabelecimentos = [{
nome:'estabelicimentos1',
lat:41.5518 ,
lng:-8.4229
},{
  nome:'estabelicimentos2',
  lat: 41.3301,
  lng:-8.2512

  }]
  constructor(public navCtrl: NavController,public geolocation: Geolocation, private platform:Platform) {}

  IonViewWillEnter(){
    this.platform.ready().then(()=>{
      this.initPage();

    })
  }

  initPage(){
    this.geolocation.getCurrentPosition().then( result =>{
      this.loadMap(result.coords.latitude,result.coords.longitude );
    })
  }

  loadMap(lat,lng){
    let LatLng=new google.maps.LatLng(lat,lng)

    let mapOptions={
      center: LatLng,
      zoom:14,
      mapTypeId: google.maps.mapTypeId.ROADMAP,
      DisableDefaultUI: true
    }
    let element=document.getElementById('map');
    this.map=new google.maps.Map(element, mapOptions)
  }
}

我的 app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';

import { IonicModule, IonicRouteStrategy } from '@ionic/angular';

import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import{HomePageModule} from './home/home.module';
import { Geolocation } from '@ionic-native/geolocation/ngx';

@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule,HomePageModule],
  providers: [ Geolocation,{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }],
  bootstrap: [AppComponent],
})
export class AppModule {}

我的主页.html

<ion-content [fullscreen]="true">

  <div id="map">
    <body>
      <div class="button_camera">
        <ion-icon name="camera"></ion-icon>
      </div>
      <div class="button_home">
        <ion-icon name="home"></ion-icon>
      </div>
      <div class="button_search">
        <ion-icon name="search"></ion-icon>
      </div>
      <div class="top-image"></div>
      <div class="button_zoom_in">
        <ion-icon name="contract"></ion-icon>
      </div>
      <div class="dot1"></div>
      <div class="dot2"></div>
      <div class="dot3"></div>
      <div class="button_zoom_out">
        <ion-icon name="expand"></ion-icon>
      </div>
    </body>
  </div>
</ion-content>

好的,我认为这就足够了,如果您需要更多信息,请告诉我,知道我知道如何在 stackoverflow 中工作,谢谢


推荐阅读