本机传输插件 - 在 ionic2 中安装后不可用 [英] Native transfer plugin - not available after install in ionic2
问题描述
我分两步在我的 ionic 2 应用程序中安装了本机 TRANSFER 插件:
1. 离子插件添加cordova-plugin-file-transfer
2. npm install --save @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-native/transfer' 导入 { 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 () 我会收到如下错误:Property 'upload' doesn't exist on type 'Transfer'.
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'.
我的技术:
科尔多瓦 CLI:6.4.0
离子框架版本:2.3.0
Ionic CLI 版本:2.2.1
离子应用程序库版本:2.2.0
离子应用脚本版本: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 Version: 2.0.0-rc.5/Ionic App Scripts Version: 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.
在app.module.ts中导入并设置为provider
Import it in app.module.ts and set as provider
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
对象.文档:Ionic Native 和 转让
这篇关于本机传输插件 - 在 ionic2 中安装后不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!