Ionic Angular 导入GooglePlus报错:类型GooglePlus不存在'ɵmod'属性
报错根因
你将GooglePlus原生服务错误添加到了Angular模块的imports数组中,imports数组仅接受带@NgModule装饰器的Angular模块类,GooglePlus是可注入的服务类,本身不是模块,因此缺少模块必备的ɵmod属性,触发此报错。
修复步骤
- 修改
tab1/tab1.module.ts文件:- 删除
imports数组中的GooglePlus项 - 在
@NgModule配置中新增providers数组,将GooglePlus加入该数组
修改后的代码如下:
- 删除
... import { Tab1PageRoutingModule } from './tab1-routing.module'; import { GoogleSignupComponent } from './google-signup/google-signup.component'; import { GooglePlus } from '@ionic-native/google-plus/ngx'; @NgModule({ imports: [ ... Tab1PageRoutingModule ], declarations: [Tab1Page, GoogleSignupComponent], providers: [GooglePlus] }) export class Tab1PageModule { }
- 额外验证点:
你当前使用的依赖版本互相适配,不需要调整版本:
- Angular 11 对应适配 @ionic-native 5.x 版本,你使用的
@ionic-native/google-plus@5.33.0符合要求 cordova-plugin-googleplus@8.5.2和上述原生封装包版本匹配- 注意该插件为原生能力,仅能在真机/模拟器环境运行,浏览器调试会触发其他原生相关报错,属于正常情况。
内容的提问来源于stack exchange,提问作者Evan
相关产品推荐
相关产品推荐

