首页 > 解决方案 > 图像到 base64 离子 3

问题描述

任何人都知道 TS 中的路线是什么,以便它获取图像并将其转换为 base64?是在 Facebook 上分享本地图片吗?

问候。

这是我的功能代码:

share(){



let filePath: string = "file:///assets/imgs/pesa4.jpg";

let shreface = this.actioSheetController.create({

  buttons:[
    {
      text:"facebook",
      icon:"logo-facebook",
      handler:()=>{
        this.base64.encodeFile(filePath).then((myBase64: string) => {
        this.socialSharing.share(this.message, this.subject, myBase64, this.url)
        console.log(myBase64);
        })
      }
    }
  ]

});
shreface.present(); 
}

在此处输入图像描述

标签: ionic-frameworkbase64

解决方案


尝试assets/imgs/pesa4.jpg删除"file:///"

如果要将本地存储映像转换为 base64,请使用文件和文件选择器插件。


推荐阅读