意外的标记。预期会使用构造函数,方法,访问器或属性。

时间:2019-07-14 16:03:59

标签: angular typescript

将免费的AdMob添加到我的ionic 4项目中。 我已将普通服务页面创建为:

import { Injectable } from '@angular/core';
import {
  AdMobFree,
  AdMobFreeBannerConfig,
  AdMobFreeInterstitialConfig,
  AdMobFreeRewardVideoConfig
} from '@ionic-native/admob-free/ngx';
import { Platform } from '@ionic/angular';


@Injectable()
export class AdmobFreeService {
  constructor(
    public adMob: AdMobFree
) { }


  const bannerConfig: AdMobFreeBannerConfig = {
    // add your config here
    // for the sake of this example we will just use the test config
    isTesting: true,
    autoShow: true
   };
   this.adMob.banner.config(this.bannerConfig);

   this.adMob.banner.prepare()
     .then(() => {
       // banner Ad is ready
       // if we set autoShow to false, then we will need to call the show method here
     })
     .catch(e => console.log(e));

}

它给我错误Unexpected token. A constructor, method, accessor, or property was expected.ts,并在此行下划线: this.adMob.banner.config(this.bannerConfig); 据我所知,这是在应用程序内部导入和调用插件的方法。需要知道导致错误的原因!?

0 个答案:

没有答案