离子2错误cordova不可用 [英] ionic 2 error cordova not available
问题描述
我正在尝试在一个新的离子2项目(最新的ionic2版本)中使用cordova GooglePlus插件,但我总是遇到有关cordova的错误。
该插件已正确安装并显示在插件文件夹中。
I am trying to use the cordova GooglePlus plugin in a new ionic 2 project (latest ionic2 version) but I always run into errors regarding cordova. The plugin is properly installed and shows up in the plugin folder.
我试过的一种方法是:
import { GooglePlus } from "ionic-native";
然后
GooglePlus.login().then(...)
登录方法执行但总是抛出错误说cordova_not_available
The login method executes but always throws an error saying "cordova_not_available"
我想用测试应用程序离开服务
在我的Windows系统上首先部署到我的Android手机之前。
如何在localhost服务器上提供cordova?从搜索中我了解cordova.js已生成并始终包含在设备的部署包中。
I want to test the app with ionic serve
on my windows system first before deploying it to my android phone.
How can I make cordova available in the localhost server? From searching I understand that cordova.js is generated and always included in the deploy package for the device.
我尝试的另一种方法是使用
Another approach I tried is using
window.plugins.googleplus.login(...)
但是这种方法没有通过对Windows对象上的插件属性一无所知的打字稿编译器。
But this approach does not go through the typescript compiler who does not know anything about a plugins property on the windows object.
我该如何修复这个?
推荐答案
如果你想让插件适用于浏览器,你应该添加平台浏览器
并运行它:
If you want the plugin to work for the browser you should add platform browser
and run it:
ionic cordova platform add browser
并运行它:
ionic cordova run browser
而不是 ionic serve
。
这篇关于离子2错误cordova不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!