angular - TypeError: Object(...) is not a function at Base64.encodeFile (vendor.js:)
问题描述
@ionic-native/base64/ngx 中的离子问题
TypeError: Object(...) is not a function at Base64.encodeFile (vendor.js:79123) at main.js:183 at t.invoke (polyfills.js:3) at Object.onInvoke (vendor.js:5134 ) 在 t.invoke (polyfills.js:3) 在 r.run (polyfills.js:3) 在 polyfills.js:3 在 t.invokeTask (polyfills.js:3) 在 Object.onInvokeTask (vendor.js:5125 ) 在 t.invokeTask (polyfills.js:3)
页面.ts
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, AlertController, ToastController, ActionSheetController, LoadingController } from 'ionic-angular';
import { RestProvider } from '../../../providers/rest/rest';
import { DatePipe } from '@angular/common';
import { FilePath } from '@ionic-native/file-path';
import { FileChooser } from '@ionic-native/file-chooser';
//import { Base64 } from '@ionic-native/base64';
import { Base64 } from '@ionic-native/base64/ngx';
//import { Camera } from '@ionic-native/camera';
import { Camera } from '@ionic-native/camera/ngx';
/**
* Generated class for the AlerteFinDroitDecesPage page.
*
* See https://ionicframework.com/docs/components/#navigation for more info on
* Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-alerte-fin-droit-deces',
templateUrl: 'alerte-fin-droit-deces.html',
})
export class AlerteFinDroitDecesPage {
constructor(public navCtrl: NavController,
public navParams: NavParams,
public Rest: RestProvider,
public alertConroller: AlertController,
public datepipe: DatePipe,
public toastCtrl: ToastController,
private fileChooser: FileChooser,
public actionSheetCtrl: ActionSheetController,
private filePath: FilePath,
public base64: Base64,
public camera:Camera,
public loadingCtrl: LoadingController) {
}
ionViewDidLoad() {
console.log('ionViewDidLoad AlertmariagePage');
}
getImage(){
// choose your file from the device
console.log("getImage");
this.fileChooser.open().then(uri => {
console.log("uri",uri);
//alert('uri'+JSON.stringify(uri));
// get file path
this.filePath.resolveNativePath(uri)
.then(file => {
//alert('file'+JSON.stringify(file));
console.log("file",file);
let filePath: string = file;
if (filePath) {
this.base64.encodeFile(filePath).then((base64File: string) => {
console.log("filePath",filePath);
console.log("base64File",base64File);
//alert('base64File'+JSON.stringify(base64File));
}, (err) => {
//alert('err'+JSON.stringify(err));
console.log("err",err);
});
}
})
.catch(err => console.log(err));
})
.catch(e => alert('uri'+JSON.stringify(e)));
}
}
请有人帮忙
解决方案
根据插件版本更新您的 base64 节点模块版本。我通过从节点模块中删除它并运行 npm install @ionic-native/base64@4.12.2 来解决它
推荐阅读
- pdf - PDF合并警告
- ios - iOS App 一键崩溃
- python - _tkinter.TclError:这不是 matplotlib 条形图中的 Tk 应用程序
- android - Android checkstyle OperatorWrap错误
- ruby-on-rails - 使用 has_scope gem Rails 显示活动过滤器
- python - 生成示例项目配置
- python - 在 Angular 4 中发布表单数据在 Django 中作为字节接收
- javascript - 从 JavaScript 中的字符串检测夏令时时区
- php - 如何对使用私有构造函数调用外部类的函数进行 PHP 单元测试
- python - 我怎样才能喜欢这张照片?python使用的模块是什么