将Angular转换为纯JavaScript



这是Ionic/Cacitor/Angular项目插件的示例代码:

import { ForegroundService } from '@awesome-cordova-plugins/foreground-service/ngx';

constructor(public foregroundService: ForegroundService) { }
...
startService() {
// Notification importance is optional, the default is 1 - Low (no sound or vibration)
this.foregroundService.start ('GPS Running', 'Background Service', 'drawable/fsicon');
}
stopService() {
// Disable the foreground service
this.foregroundService.stop();
}

我不熟悉Angular,也没有简单的JavaScript(不是Typescript(示例。这段代码在纯JavaScript中会是什么样子?

我不是Ionic专家,但在阅读了文档后,我打赌它应该这样使用:

// import without `ngx`
import { ForegroundService } from '@awesome-cordova-plugins/foreground-service';
// create the object from class
const foregroundService = new ForegroundService();
// start the service
foregroundService.start('GPS Running', 'Background Service', 'drawable/fsicon');
// stop the service
foregroundService.stop()

在React部分了解更多关于使用离子天然成分的信息特别有用

最新更新