Ionic2 Cordova插件无法访问

时间:2016-07-17 16:24:13

标签: cordova angular cordova-plugins ionic2

我在ionic2项目中安装了x-toaster插件:

get { value in
 //Now you have your value retrieved from firebase and you can use it however you want.
 print(value)
 self.currentVote = value
//your other code
}

在Code中我尝试:

cordova plugin add cordova-plugin-x-toast --save

上面似乎没有掌握插件。

enter image description here

我的组件:

window['plugins'].toast.show(message, "short", position);

2 个答案:

答案 0 :(得分:0)

import { Toast } from 'ionic-native'

然后在代码中执行Toast.

..但是它仍然没有显示,幸运的是所有控制台错误都消失了。欢迎任何想法。

答案 1 :(得分:0)

您有两个选择:

1)

import . . .
import . . .
declare var cordova;
. 
.
.
cordova.plugins.toast.show(message, "short", position);

2)

(<any>window).plugins.toast.show(message, "short", position);