【问题标题】:ionic cordova build android --prod typescript errorionic cordova build android --prod typescript 错误
【发布时间】:2019-10-05 20:39:15
【问题描述】:

我可以使用“ionic cordova build android”构建我的 ionic 项目,但该应用在设备上运行缓慢。经过一些研究,我了解到应该使用“ionic cordova build android --prod”来构建它以提高性能。然而,这是我在运行“ionic cordova build android --prod”时遇到的错误

Type PinnedmessagesComponent in project/src/components/pinnedmessages/pinnedmessages.ts is part of the declarations of 2 modules: 

ComponentsModule in project/src/components/components.module.ts and
        ProfilePageModule in project/src/pages/profile/profile.module.ts! 

Please consider moving PinnedmessagesComponent in project/src/components/pinnedmessages/pinnedmessages.ts to a higher module that imports ComponentsModule in project/src/components/components.module.ts and 
ProfilePageModule in project/src/pages/profile/profile.module.ts. 

You can also create a new NgModule that exports and includes PinnedmessagesComponent in project/src/components/pinnedmessages/pinnedmessages.ts then import that NgModule in ComponentsModule in project/src/components/components.module.ts and 
ProfilePageModule in project/src/pages/profile/profile.module.ts.

Pinnedmessages 是我创建的一个组件,我在另一个名为 ProfilePage 的页面中使用它。请告诉我如何解决这个问题。谢谢

【问题讨论】:

    标签: angular typescript ionic-framework


    【解决方案1】:

    错误告诉你它想要什么。为该组件创建一个模块,然后将该模块包含在您需要该组件的位置。它不喜欢你有两个组件声明,所以它希望你在一个模块中有一个,然后导入那个模块。

    【讨论】:

    • 感谢您的回复,但该模块已作为 import { PinnedmessagesComponent} from '../../components/pinnedmessages/pinnedmessages' 包含在 ProfilePage 中,并且在 @NgModule 声明下我有这个:PinnedmessagesComponent
    • 对,但请检查profile.module.tscomponents.module.ts 的声明。两者都声明了吗?
    猜你喜欢
    • 1970-01-01
    • 2019-04-19
    • 2023-03-31
    • 1970-01-01
    • 2018-12-14
    • 2018-05-12
    • 1970-01-01
    • 2019-06-27
    • 1970-01-01
    相关资源
    最近更新 更多