如何在不使用离子原生的情况下使用插件? [英] How to use a plugin without using ionic-native?

查看:137
本文介绍了如何在不使用离子原生的情况下使用插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想添加cordova插件: cordova-plguin-ms-adal 。因为离子原生不支持此插件。我不知道如何实现自己,所以我打开一个问题,并希望他们很快就能合并这个插件。

I want add the cordova plugin: cordova-plguin-ms-adal. Because this plugin is not supported in the ionic-native. I don't know how to implement myself, so I open an issue and hope they will merge this plugin very soon.

与此同时,我等不及了。那么有没有办法在不使用离子原生的情况下使用这个插件?

In the meantime, I can't wait. So is there any way to use this plugin without using ionic-native?

我在 home.ts 中尝试了以下代码,但是失败了到达。

I tried the following code in my home.ts, but failed to reach.


windows.plugins.Microsoft.ADAL.AuthenticationContext(s);

或直接


Microsoft.ADAL.AuthenticationContext(s);

注意:
- Microsoft和ADAL是插件名称空间
- AuthenticationContext是函数

Note: - Microsoft and ADAL are the namespaces of the plugin - AuthenticationContext is the function

推荐答案

您可以在ionic2中使用cordova插件,但离子本机不支持插件。将所需的插件添加到项目中。

You can use cordova plugin in ionic2 though the plugin is not supported by ionic-native. Add the required plugin to your project.

打开文件 Plugins.xml 并检查目标 clobbers 标记下的值。在您的情况下,它是Microsoft.ADAL.AuthenticationContext,其中<​​strong> Microsoft 是基类。

Open the file "Plugins.xml" and check for the target value under clobbers tag. In your case, it is Microsoft.ADAL.AuthenticationContext where Microsoft is the base class.

打开要使用插件的ts文件。使用声明在导入时输入Microsoft:any; 它是一个基类。然后将该方法调用为 Microsoft.ADAL.AuthenticationContext.your_method()

Open the ts file where you want to use the plugin.Use declare var Microsoft: any;under import as it is a base class. Then call the method as Microsoft.ADAL.AuthenticationContext.your_method()

这篇关于如何在不使用离子原生的情况下使用插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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