我已经使用 angular 来创建我的项目,并且效果很好。
现在我试图将它包装在一个 Cordova 项目中,但我不知道如何在 de Angular 代码中使用我需要的一些 Cordova 插件......
我能怎么做?我正在尝试使用cordova-plugin-android-volume设置设备的音量(我只对android感兴趣)
您可以添加cordova-plugin-android-volume
使用
cordova plugin add https://github.com/MCluck90/cordova-plugin-android-volume.git
现在,由于您使用的是 angular 和 Typescript,因此您需要先声明cordova
和androidVolume
才能使用。使用declare
关键字查看下面的代码
import { Component } from '@angular/core';
declare var cordova: any;
declare var window: any;
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
setVolume() {
console.log(cordova);
console.log(window.androidVolume);
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句