Cordova:在哪里以及如何安装插件?(Cordova: where and how install a plugin?)

编程入门 行业动态 更新时间:2024-10-14 14:17:17
Cordova:在哪里以及如何安装插件?(Cordova: where and how install a plugin?)

我创建了一个全新的应用程序。

然后我去了www目录并执行了npm install cordova-plugin-file 。

现在? 在应用程序中使用此插件我该怎么办?

如果我做一个cordova plugin list它只向我显示白名单插件,默认情况下从cordova本身创建。

然后我尝试了cordova plugin add cordova-plugin-file ,现在cordova plugin list显示了白名单和文件插件。

现在? 当我尝试以下代码时,我得到了,在Android模拟器上,cordova.file undefined

window.resolveLocalFileSystemURL(cordova.file.dataDirectory, function(dir) { console.log("got main dir", dir); });

I created a fresh new app.

Then I went to the www directory and executed npm install cordova-plugin-file.

And now? What must I do to work with this plugin in the app?

If I do a cordova plugin list it shows me only the whitelist plugin, created by default from cordova itself.

I then tried cordova plugin add cordova-plugin-file and now cordova plugin list shows me both whitelist and file plugin.

And now? When I tried the following code I got that, on Android emulator, cordova.file is undefined

window.resolveLocalFileSystemURL(cordova.file.dataDirectory, function(dir) { console.log("got main dir", dir); });

最满意答案

cordova-plugin-file插件仅适用于真实手机,不适用于模拟器。

您可以将应用安装到手机上并进行调试。

在控制台中,您将获得预期的日志。

The problem here was simply that the whole app must be wrapped into the deviceReady event handler, but ... not this code ... damn... now it works

更多推荐

cordova,plugin,file,现在,电脑培训,计算机培训,IT培训"/> <meta name="descri

本文发布于:2023-08-07 05:49:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1463040.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:插件   Cordova   plugin   install

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!