我使用"离子加载控制器"来显示一个微调器,直到检索到数据然后它调用"dismiss()"来解除它.它工作正常,但有时当应用程序已经拥有数据时,在"create()"和"present()"完成之前调用"dismiss()",这将保持微调器而不会消失...
我试图在"loadingController.present().then()"中调用数据,但这导致数据变慢...
这是一个错误吗?如何解决这个问题?
我的代码示例:
customer: any;
constructor(public loadingController: LoadingController, private customerService: CustomerService)
ngOnInit() {
this.presentLoading().then(a => consloe.log('presented'));
this.customerService.getCustomer('1')
.subscribe(customer => {
this.customer = customer;
this.loadingController.dismiss().then(a => console.log('dismissed'));
}
}
async presentLoading() {
const loading = await this.loadingController.create({
message: 'wait. . .',
duration: 5000
});
return await loading.present();
}
Run Code Online (Sandbox Code Playgroud) 我试图用离子本地插件geolocation中ionic 4,但我得到了这个错误:
编译失败.
./node_modules/@ionic-native/geolocation/index.js找不到模块:错误:无法解析'C:\ Projects\ionic\prayers \node_modules\@ ionic-native\geolocation'中的'rxjs/Observable'
这是我的依赖:
"dependencies": {
"@angular/common": "6.0.9",
"@angular/core": "6.0.9",
"@angular/forms": "6.0.9",
"@angular/http": "6.0.9",
"@angular/platform-browser": "6.0.9",
"@angular/platform-browser-dynamic": "6.0.9",
"@angular/router": "6.0.9",
"@ionic-native/core": "5.0.0-beta.14",
"@ionic-native/geolocation": "^4.11.0",
"@ionic-native/splash-screen": "5.0.0-beta.14",
"@ionic-native/status-bar": "5.0.0-beta.14",
"@ionic/angular": "4.0.0-beta.0",
"@ionic/ng-toolkit": "1.0.0",
"@ionic/schematics-angular": "1.0.1",
"cordova-plugin-geolocation": "^4.0.1",
"core-js": "^2.5.3",
"rxjs": "6.2.2",
"zone.js": "^0.8.26"
},
Run Code Online (Sandbox Code Playgroud)
这是我使用的代码: -
app.module.ts
import { Geolocation } from '@ionic-native/geolocation';
...
NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
providers: [
StatusBar,
SplashScreen, Geolocation,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy …Run Code Online (Sandbox Code Playgroud) 我试图使用离子4 google-maps@5.0.0-beta.20
我正在关注以下幻灯片:https://docs.google.com/presentation/d/1zlkmoSY4AzDJc_P4IqWLnzct41IqHyzGkLeyhlAxMDE/edit#slide=id.g282d0a7bfd_0_140
我收到此错误:"TypeError:无法读取属性'BaseClass'的null"
newlocation.page.html:
<ion-content>
<h3>Ionic GoogleMaps Starter</h3>
<div id="map_canvas">
</div>
</ion-content>
Run Code Online (Sandbox Code Playgroud)
newlocation.page.scss:
map_canvas {
height: 90%;
}
Run Code Online (Sandbox Code Playgroud)
newlocation.page.ts:
import { Component, OnInit } from '@angular/core';
import { Platform } from '@ionic/angular';
import { GoogleMaps, GoogleMap } from '@ionic-native/google-maps';
@Component({
selector: 'app-newlocation',
templateUrl: './newlocation.page.html',
styleUrls: ['./newlocation.page.scss'],
})
export class NewlocationPage implements OnInit {
map: GoogleMap;
constructor(private platform: Platform) { }
async ngOnInit() {
await this.platform.ready();
await this.loadMap();
}
loadMap() {
this.map = GoogleMaps.create('map_canvas');
}
}
Run Code Online (Sandbox Code Playgroud)
的package.json: …
angular ×3
ionic4 ×3
ionic-native ×2
angular6 ×1
geolocation ×1
google-maps ×1
loading ×1
rxjs ×1