【问题标题】:Failed to load resource: the server responded with a status of 404 (cordova)加载资源失败:服务器响应状态为 404 (cordova)
【发布时间】:2021-02-11 19:23:01
【问题描述】:

enter image description here

我不知道会发生什么,但是 ionic 无法加载cordova,并且打印中的cordova 是写在代码中的,我该如何修复它

【问题讨论】:

  • 你能提供更多的见解吗?你想加载什么?它在任何时候都有效吗?如果您尝试“加载”cordova,Index.html 中的 CDN 不是办法。你熟悉 npm 吗?
  • @Haythem 是的,我已经使用 npm 了,我的项目是使用 ionic 为 moblie 使用 gps,所以我已经更改了 css 并进行了项目设计,在 home.page 中调用了地理位置和谷歌地图.ts 并在其中执行一些功能,我已经有了 api 密钥,再见了谷歌服务,这是我第一次使用堆栈溢出,所以我无法解释:/
  • 你先分享一个问题的截图怎么样?还提供您遇到问题的代码可能会有所帮助。还有Here's how to ask questions
  • 我已经发布了命令中显示的问题的屏幕截图并添加了一些代码

标签: cordova ionic-framework indexing scripting


【解决方案1】:

enter image description here

我的主页 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 {}

我的主页.page.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 中工作,谢谢

【讨论】:

    猜你喜欢
    • 2016-11-01
    • 2018-01-29
    • 2020-07-04
    • 1970-01-01
    • 2016-01-04
    • 1970-01-01
    • 2019-07-04
    相关资源
    最近更新 更多