我创建了一个全新的应用程序。
然后我去了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
发布评论