问题描述
如果没有出现此错误,我无法导入 GooglePlus。
控制台错误
ERROR Error: Uncaught (in promise): Error: Type GooglePlus does not 具有 'ɵmod' 属性。 getNgModuleDef@http://localhost:8100/vendor.js:57098:15 recurse@http://localhost:8100/vendor.js:81227:35 recurse@http://localhost:8100/vendor.js:81238:24
tab1/tab1.module.ts
...
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,GooglePlus
],declarations: [Tab1Page,GoogleSignupComponent],})
export class Tab1PageModule { }
tab1/google-signup/google-signup.component.ts
...
import { GooglePlus } from '@ionic-native/google-plus/ngx';
@Component({
selector: 'app-google-signup',templateUrl: './google-signup.component.html',styleUrls: ['./google-signup.component.scss'],})
export class GoogleSignupComponent implements OnInit {
constructor(private googlePlus: GooglePlus) { }
ngOnInit() { }
public google() {
console.log('google signup');
this.googlePlus.login({})
.then(res => console.log(res))
.catch(err => console.error(err));
}
...
}
我正在使用:
- 角度 11
- "@ionic-native/google-plus": "^5.33.0"
- "cordova-plugin-googleplus": "^8.5.2",
解决方法
您正在尝试在 GooglePlus
导入中导入 ngModule
。没有必要这样做。 Docs
编辑:
有时您需要将插件作为 provider
添加到您的 ngModule
。你可以试试这个:
@NgModule({
imports: [...],providers: [GooglePlus],...