繁体   English   中英

将 Angular 转换为普通 JavaScript

[英]Convert Angular to plain JavaScript

这是 Ionic/Capacitor/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 部分了解有关使用 Ionic Native 组件的更多信息特别有用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM