Я новичок для ионных приложений, и я пытаюсь сделать снимок, используя приведенный ниже код, но я получаю исключение, подобное Не удалось получить свойство 'DestinationType' с неопределенной или нулевой ссылкой , и я добавил ниже два плагинав мой проект
может кто-нибудь помочь мне, пожалуйста
$ плагин ionic cordova добавить cordova-plugin-camera-preview $ npm install --save @ ionic-native / camera-preview
home.ts:
export class HomePage {
public base64Image: string;
public photos : any;
constructor(private camera: Camera) {
}
takePhoto() {
const options : CameraOptions = {
quality: 50, // picture quality
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
}
this.camera.getPicture(options) .then((imageData) => {
this.base64Image = "data:image/jpeg;base64," + imageData;
}, (err) => {
console.log(err);
});
}
}
home.html:
<ion-header>
<ion-navbar>
<ion-title>
Ionic Blank
</ion-title>
</ion-navbar>
</ion-header>
<ion-content class="home">
<ion-card>
<ion-card-content>
Hello World, this is my camera app
<button (click)="takePhoto()">Take a Picture</button>
Latest Picture:
<img [src]="base64Image" *ngIf="base64Image" />
</ion-card-content>
</ion-card>
</ion-content>
app.module.ts:
@NgModule({
declarations: [
MyApp,
HomePage
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage
],
providers: [
StatusBar,
SplashScreen,
CameraPreview
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}