Ionic 电容器V3状态条给出该误差:型别'SplashScreenPlugin'无法指派给型别'Provider'

jdg4fx2g  于 2022-12-09  发布在  Ionic
关注(0)|答案(1)|浏览(104)

我正在运行带有电容器3的离子6+。我安装了电容器状态栏和闪屏,如下所示:

npm install @capacitor/status-bar --save
npm install @capacitor/splash-screen --save

npx cap sync

然后像这样导入:

import { SplashScreen } from '@capacitor/splash-screen';
import { StatusBar, Style } from '@capacitor/status-bar';

然后是:

@NgModule({
  ..........
..........
 providers: [ StatusBar,
              SplashScreen,
             .......
             ]

vscode会将StatusBar和闪屏标记为以下错误:

Type 'StatusBarPlugin' is not assignable to type 'Provider'.
Type 'SplashScreenPlugin' is not assignable to type 'Provider'.

我也试着切换回使用@ionic-native/splash-screen/ngx'和@ionic-native/status-bar/ngx',即使这样清除了提供程序错误,我还是收到了来自ivy的警告,这些插件需要更新。
谁能解释一下为什么会出现这个错误?

5sxhfpxr

5sxhfpxr1#

您不必将插件注册为提供者。只需在您的服务/组件/等中使用它们:

import { Component } from '@angular/core';
import { Badge } from '@robingenz/capacitor-badge';

@Component({
  selector: 'app-badge',
  templateUrl: './badge.page.html',
  styleUrls: ['./badge.page.scss'],
})
export class BadgePage {
  constructor() {}

  public async getBadgeCount(): Promise<number> {
    const result = await Badge.get();
    return result.count;
  }
}

相关问题