Ionic 3项目无法通过抛出错误来生成生产apk

时间:2019-07-16 09:31:23

标签: angular typescript ionic-framework ionic3 angular6

当我输入ionic cordova build android --prod时,会引发以下错误: 无法确定src./components/search/filter.pipe.ts中FilterPipe类的模块。将过滤器管道添加到模块以对其进行修复:

这是组件模块:

import { IonicModule } from 'ionic-angular';
import { NgModule } from '@angular/core';
import { ImagesComponent } from './images/images';
import { SearchComponent } from './search/search';
import { FilterPipe } from '../pipes/filter.pipe';
import { SocketIoModule, SocketIoConfig } from 'socket.io-client';
const config: SocketIoConfig = { url: 'http://localhost:3001', options: {} };

@NgModule({
  declarations: [PostsComponent, UserFriendsComponent,
    ImagesComponent, SearchComponent,
    FilterPipe,
    PeopleListComponent],
  imports: [IonicModule,
  ],
  exports: [ImagesComponent, SearchComponent,
    PeopleListComponent]
})
export class ComponentsModule { }

我没有在app.module中添加内容,而是在components模块中添加了它。但是问题是,即使我将其移至app.module,也会发生相同的问题。这也是过滤器管道的代码:

import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
    name: 'filter',
})
export class FilterPipe implements PipeTransform {
    transform(items: any[], value: string, prop: string): any[] {
        if (!items) return [];
        if (!value) return items;

        return items.filter(singleItem =>
            singleItem[prop].toLowerCase().includes(value.toLowerCase())
        );

    }
}

如何解决此问题并生成可成功测试的生产APK?

0 个答案:

没有答案