我正在使用 Visual Studio 2017 中的 Cordova 应用程序,我正在尝试使用文件插件访问文件系统。不幸的是,这在使用“在浏览器中模拟”(使用 cordova-simulate)调试应用程序时不起作用。
“安全错误:确定某些文件在 Web 应用程序中访问不安全,或者对文件资源进行了太多调用。”引发错误。
我想是否必须将“--allow-file-access-from-files”选项传递给chrome,但我不知道该怎么做,因为chrome会在新窗口中自动启动,我找不到任何配置选项在 Visual Studio 中。
最佳答案
一些 Chrome Quirks是:
filePluginIsReady
事件。示例: javascript
window.addEventListener('filePluginIsReady', function(){ console.log('File plugin is ready');}, false);
您可以使用 window.isFilePluginReadyRaised
检查事件是否已经引发的函数。 window.initPersistentFileSystem
方法。默认情况下,持久存储配额为 5 MB。 file:///
运行参数以支持 API协议(protocol)。 {create:true}
,对象将不会更改获取现有的 Entry
时. 表格上面的怪癖使用基本步骤here :
At the time of writing this article, Google Chrome has the only working implementation of the FileSystem API. A dedicated browser UI does not yet exist for file/quota management. To store data on the user's system, may require your app to request quota. However, for testing, Chrome can be run with the --unlimited-quota-for-files flag. Furthermore, if you're building an app or extension for the Chrome Web Store, the unlimitedStorage manifest file permission can be used in place of requesting quota. Eventually, users will receive a permission dialog to grant, deny, or increase storage for an app.
You may need the --allow-file-access-from-files flag if you're debugging your app from file://. Not using these flags will result in a SECURITY_ERR or QUOTA_EXCEEDED_ERR FileError.
关于visual-studio - Cordova:使用 VS 2017 中的 --allow-file-access-from-files 启动 chrome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47154220/