本机传输插件 - 在ionic2中安装后不可用 [英] Native transfer plugin - not available after install in ionic2

查看:75
本文介绍了本机传输插件 - 在ionic2中安装后不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的离子2应用程序中分两步安装了原生TRANSFER插件:

1.离子插件添加cordova-plugin-file-transfer

2. npm install - 保存@ ionic-native / transfer

I have installed native TRANSFER plugin in my ionic 2 app in 2 steps:
1. ionic plugin add cordova-plugin-file-transfer
2. npm install --save @ionic-native/transfer

之后我在home.ts页面导入了插件。

从'@ionic导入{Transfer} -native / transfer'

After that i imported the plugin in my home.ts page.
Import { Transfer } from '@ionic-native/transfer'

我试图使用插件上传文件
var ft = new Transfer();

I tried to use the plugin to upload a file var ft = new Transfer();

但是我不能使用ft var,因为Transfer插件看起来不可用。
如果我写ft.upload()我收到如下错误:转移类型中不存在上传属性

But i can't use ft var, because Transfer plugin look like it's not avalable. If i write ft.upload () i receive an error like: Property 'upload' does not exist on type 'Transfer'.

我的技术:

Cordova CLI:6.4.0

Ionic Framework版本:2.3.0

Ionic CLI版本:2.2.1

Ionic App Lib版本:2.2.0

Ionic App脚本版本:1.1.4

My technologies:
Cordova CLI: 6.4.0
Ionic Framework Version: 2.3.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.1.4

在我的应用程序的早期版本中使用 Ionic Framework版本:2.0.0-rc.5 / Ionic App Scripts版本:1.0.0 一切正常。

In the previous version of my app when using Ionic Framework Version: 2.0.0-rc.5 /Ionic App Scripts Version: 1.0.0 all worked just fine.

有没有人对此有什么解决方案吗?
提前致谢。

Does anyone has any solution for this? Thanks in advance.

推荐答案

在Ionic Native的 3.1.0版本

In the 3.1.0 version of Ionic Native, you have to use the plugin like a provider.


  1. 将其导入 app.module.ts 并设置为提供者

 import {Transfer} from '@ionic-native/transfer'

 @ngModule({
   //...
   providers:[
       Transfer,
       ..]


  • 在您需要使用它的组件/提供商中注入。

  • Inject in the component/provider where you need to use it.

    constructor(private fileTransfer:Transfer){}
    


  • 使用 fileTransfer 对象。

  • Use the fileTransfer object.
  • 文档: Ionic Native 转移

    这篇关于本机传输插件 - 在ionic2中安装后不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆