我使用离子cli使用此命令生成页面
ionic generate page login
ionic g page login
然后我在浏览器中收到此错误
Typescript Error
Property 'forChild' does not exist on type 'typeof IonicModule'.
E:/workspace/Ionic/myApp/src/pages/login/login.module.ts
imports: [
IonicModule.forChild(Login),
],
还在登录文件夹中创建4个项目。
1.login.html
2.login.ts
3.login.module.ts
4.login.scss
任何人都可以解决这个问题。 这是login.module.ts
import { NgModule } from '@angular/core';
import { IonicModule } from 'ionic-angular';
import { Login } from './login';
@NgModule({
declarations: [
Login,
],
imports: [
IonicModule.forChild(Login),
],
exports: [
Login
]
})
export class LoginModule {}
如果我删除此行,应用程序可以正常工作。
IonicModule.forChild(Login),
答案 0 :(得分:14)
有
IonicModule.forRoot(MyApp)
。
Github链接here。
export class IonicModule {
/**
* Set the root app component for you IonicModule
* @param {any} appRoot The root AppComponent for this app.
* @param {any} config Config Options for the app. Accepts any config property.
* @param {any} deepLinkConfig Any configuration needed for the Ionic Deeplinker.
*/
static forRoot(appRoot: any,
config: any = null,
deepLinkConfig: DeepLinkConfig = null): ModuleWithProviders {
要启动单个页面,您可以尝试IonicPageModule。
@NgModule({
imports: [IonicModule],
exports: [IonicModule]
})
export class IonicPageModule {
static forChild(page: any): ModuleWithProviders {
将导入更改为:
imports: [
IonicPageModule.forChild(Login),
]
更新
相关链接:IonicPage, IonicPageModule
根据google docs中共享的discussion here,ionic 3
中介绍了延迟加载离子页面的内容。