如何解决加载资源失败:服务器响应状态为 404 (cordova)
我不知道会发生什么,但是离子无法加载cordova,并且打印的cordova是写在代码中的,我该如何修复它
解决方法
我的主页 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 {}
我的 home.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 中工作,谢谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。