ionic 2 错误科尔多瓦不可用 [英] ionic 2 error cordova not available

查看:27
本文介绍了ionic 2 错误科尔多瓦不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在一个新的 ionic 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.

我尝试过的一种方法是:

One approach I tried is this:

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 系统上使用 ionic serve 测试应用程序,然后再将其部署到我的 Android 手机.如何使科尔多瓦在 localhost 服务器中可用?通过搜索,我了解到 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 对象上的 plugins 属性一无所知的 typescript 编译器.

But this approach does not go through the typescript compiler who does not know anything about a plugins property on the windows object.

我该如何解决这个问题?

How can I fix this?

推荐答案

如果您希望插件适用于浏览器,您应该添加 platform browser 并运行它:

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.

这篇关于ionic 2 错误科尔多瓦不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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