Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ionic framework ionic无法在LoginComponent中使用IonicStorageModule_Ionic Framework_Local Storage - Fatal编程技术网

Ionic framework ionic无法在LoginComponent中使用IonicStorageModule

Ionic framework ionic无法在LoginComponent中使用IonicStorageModule,ionic-framework,local-storage,Ionic Framework,Local Storage,我正在使用IonicStorage在本地存储凭据。在我的app.component中,它工作正常。之后,我使用ionic generate创建了一个新组件,之后我编写了以下代码: constructor(private http: HttpClient, private toastController: ToastController, private router: Router, private storage: Storage) { } private store

我正在使用IonicStorage在本地存储凭据。在我的app.component中,它工作正常。之后,我使用ionic generate创建了一个新组件,之后我编写了以下代码:

 constructor(private http: HttpClient, private toastController: ToastController, private router: Router,
          private storage: Storage) { }

 private storeData() {

// @ts-ignore
this.storage.set('email', this.login.email);
// @ts-ignore
this.storage.set('pw', this.login.pw);
this.storage.set('lastlogin', Math.round(new Date().getTime()/1000));
}

这是我的应用程序模块:

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

import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { IonicStorageModule } from '@ionic/storage';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import {HttpClientModule} from "@angular/common/http";
import {FormsModule} from "@angular/forms";

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

你能包括从你的登录组件导入的内容吗?是的,这就是问题所在,谢谢!是的,我也有同样的问题很多次了!为了结束这个问题,你介意添加这个作为答案并接受它吗?:)