我是离子框架的新手,所以我真的需要您的帮助。 我的问题是,每当我向离子UI组件添加属性时,它就根本无法工作。例如:
<button ion-button color="secondary" clear>Secondary Clear</button>
<ion ion-button color="light" outline>Light Outline</button>
<button ion-button full>Full Button</button>
颜色确实适用,但它们的属性却不适用。另一个例子是
<ion-list>
<ion-item>
<ion-label floating>Username</ion-label>
<ion-input type="text"></ion-input>
</ion-item>
<ion-item>
<ion-label floating>Password</ion-label>
<ion-input type="password"></ion-input>
</ion-item>
</ion-list>
对此,浮动属性也不适用。因此,我意识到离子属性实际上对我不起作用,我也不知道为什么。这是我的app.module.ts文件
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpModule } from '@angular/http';
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 { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [BrowserModule, HttpModule, IonicModule.forRoot(), AppRoutingModule],
providers: [
StatusBar,
SplashScreen,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent]
})
export class AppModule {}
答案 0 :(得分:2)
您的app.module.ts
应该如下所示:
@NgModule({
declarations: [
MyApp,
HomePage // declear your Page inside declarations
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp),
HttpClientModule,
HttpModule,
IonicStorageModule.forRoot(),
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage // ALSO inside bootstrap entryComponemt
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler,}
]
})
export class AppModule {}
这将为您解决问题。