使用`--prod`建立离子滚动头包问题(请添加@NgModule注释。)

问题描述 投票:8回答:4

git仓库中有一个包

https://github.com/keephacking/ionic-scrolling-header

有一切使它兼容aot。但在使用时构建我的应用程序

ionic build --prod命令,aot build失败,错误如下所示。

[18:02:48]  ngc started ...
[18:02:57]  typescript error
        Unexpected value 'ScrollingHeaderModule in
        xxx/node_modules/ionic-scrolling-header/scrolling-header.module.d.ts' imported by the
        module 'xxxModule in xxx/xxx.module.ts'. Please add a @NgModule
        annotation.

Error: The Angular AoT build failed. See the issues above
at xxx\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:237:55
at step (xxx\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:32:23)
at Object.next (xxx\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:13:53)
at fulfilled (xxx\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:4:58)
[18:02:57]  copy finished in 10.69 s

我在Package.json中的依赖项

{
   "dependencies": {
    "@angular/common": "5.2.0",
    "@angular/compiler": "5.2.0",
    "@angular/compiler-cli": "5.2.0",
    "@angular/core": "5.2.0",
    "@angular/forms": "5.2.0",
    "@angular/http": "5.2.0",
    "@angular/platform-browser": "5.2.0",
    "@angular/platform-browser-dynamic": "5.2.0",
    "@ionic-native/core": "4.4.2",
    "@ionic/storage": "2.1.3",
    "es6-promise-plugin": "^4.1.1",
    "firebase": "^4.8.0",
    "ionic-angular": "3.9.2",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "promise-polyfill": "^7.0.0",
    "rxjs": "5.5.6",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.18"
  },
  "devDependencies": {
    "@angular/cli": "^1.6.3",
    "@ionic/app-scripts": "3.1.7",
    "typescript": "2.6.2"
  }
}

非常好奇地知道那个包里丢失了什么。

谢谢

angular npm ionic2 ionic3 angular5
4个回答
1
投票

我按照以下步骤操作,它对我有用,希望它能帮到你

第1步:安装npm install ionic-scrolling-header --sav-dev

第2步:打开你的home.moduel.ts文件并导入这个import {ScrollingHeaderModule} from 'ionic-scrolling-header';,不要忘记在你的导入中添加这个

imports: [
    ScrollingHeaderModule,
    IonicPageModule.forChild(HomePage),
  ],

第3步:在你的home.ts文件中添加这个@ViewChild(Content) content: Content;

第4步:在home.html页面内添加此<ion-header [scrollingHeader]='content'>

有关更多信息,请查看此link


1
投票

我已按照以下步骤进行修复:

0-Download project from author repository
1-Rename "src" folder to "ionic-scrolling-header", and copy to your directive(folder)
2-Create a directive folder inside src (folder)
3-Change import in your app.module.ts, as you can see on my print:

screenshot


0
投票

当我的tsconfig.json没有发出声明文件时,我遇到了这个错误。

确保在构建ScrollingHeaderModule的代码库中的tsconfig.json中包含以下内容:

"declaration": true,


0
投票

该问题已在最新版本的ionic-scrolling-header包中修复。

npm install ionic-scrolling-header@latest将解决它。

© www.soinside.com 2019 - 2024. All rights reserved.