Chrome中的cordova-plugin-file:未定义cordova [英] cordova-plugin-file in Chrome: cordova is not defined

查看:399
本文介绍了Chrome中的cordova-plugin-file:未定义cordova的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的离子应用程序中使用cordova-plugin-file下载图像并保存到本地。

I use cordova-plugin-file in my ionic app to download images and save to local.

当我在模拟器或iphone中运行它时,没有错误,但是当我在Chrome中测试它时,当我尝试访问 cordova.file.dataDirectory cordova未定义 c>

When I run it in emulator or iphone, there is no error, but when I test it in Chrome, it says, cordova is not defined when I try to access cordova.file.dataDirectory

如何在chrome中运行cordova-plugin-file?

How can I run cordova-plugin-file in chrome?

推荐答案

Cordova将无法在浏览器中使用;仅在您的设备上。

Cordova will not be available in the browser; only on your device.

在您的 index.html 中,您应该有以下脚本参考:

In your index.html you should have this script reference:

<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>

正如笔记所说,在开发过程中脚本将不可用。
它将在构建过程中被替换。

As the note says, the script won't be available during the development. It will be replaced during the build process.

你可以自己试试:

cordova platform add android

然后

cordova build

你应该找到 platforms \ android \\ \ sets\www 2个js文件: cordova.js cordova_plugins.js

and you should find under platforms\android\assets\www 2 js files: cordova.js and cordova_plugins.js.

另一种选择是将浏览器添加为平台:

Another option is to add browser as platform:

cordova platform add browser

并运行它:

cordova run browser

但您可能会面临一些麻烦。

but you might face a few troubles.

这篇关于Chrome中的cordova-plugin-file:未定义cordova的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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