我正在运行带有电容器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和SplashScreen标记为以下错误:
Type 'StatusBarPlugin' is not assignable to type 'Provider'.
Type 'SplashScreenPlugin' is not assignable to type 'Provider'.我还尝试切换到使用@离子型本机/溅屏/ngx和@离子型本机/状态栏/ngx‘,尽管这清除了提供者的错误,但我收到常春藤的警告,这些插件需要更新。
有人能解释一下这个错误发生的原因吗?
发布于 2022-06-18 20:03:41
您不必将插件注册为提供程序。只需在服务/组件/等等中使用它们:
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;
}
}https://stackoverflow.com/questions/72672091
复制相似问题