【问题标题】:Ionic Angular - Error: Type GooglePlus does not have 'ɵmod' propertyIonic Angular - 错误:GooglePlus 类型没有“ɵmod”属性
【发布时间】:2021-08-09 02:28:11
【问题描述】:

如果没有出现此错误,我无法导入 GooglePlus。

控制台错误

ERROR 错误:未捕获(承诺中):错误:GooglePlus 类型不 有 'ɵ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”,

【问题讨论】:

    标签: angular ionic-framework ionic5 google-plus-signin


    【解决方案1】:

    您正在尝试在 ngModule 导入中导入 GooglePlus。没有必要这样做。 Docs

    编辑:

    有时您需要将插件作为provider 添加到您的ngModule。你可以试试这个:

    @NgModule({
    imports: [...],
    providers: [GooglePlus],
    ...
    

    【讨论】:

      猜你喜欢
      • 2021-05-06
      • 2021-06-18
      • 1970-01-01
      • 2021-10-19
      • 1970-01-01
      • 2021-07-10
      • 1970-01-01
      • 2021-06-19
      • 1970-01-01
      相关资源
      最近更新 更多