visual-studio - Cordova:使用 VS 2017 中的 --allow-file-access-from-files 启动 chrome

标签 visual-studio cordova visual-studio-2017 visual-studio-cordova

我正在使用 Visual Studio 2017 中的 Cordova 应用程序,我正在尝试使用文件插件访问文件系统。不幸的是,这在使用“在浏览器中模拟”(使用 cordova-simulate)调试应用程序时不起作用。

“安全错误:确定某些文件在 Web 应用程序中访问不安全,或者对文件资源进行了太多调用。”引发错误。

我想是否必须将“--allow-file-access-from-files”选项传递给chrome,但我不知道该怎么做,因为chrome会在新窗口中自动启动,我找不到任何配置选项在 Visual Studio 中。

最佳答案

一些 Chrome Quirks是:

  • 设备就绪事件后 Chrome 文件系统未立即就绪。作为一种解决方法,您可以订阅 filePluginIsReady事件。
    示例: javascript window.addEventListener('filePluginIsReady', function(){ console.log('File plugin is ready');}, false);您可以使用 window.isFilePluginReadyRaised检查事件是否已经引发的函数。
  • window.requestFileSystem TEMPORARY 和 PERSISTENT 文件系统配额在 Chrome 中不受限制。
  • 要增加 Chrome 中的持久存储,您需要调用 window.initPersistentFileSystem方法。默认情况下,持久存储配额为 5 MB。
  • Chrome 需要 --allow-file-access-from-files 通过 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/

    相关文章:

    c++ - 包含 .h 时 CUDA 报告 Unresolved inclusion

    c# - 如果我支持 VS2015,我的分析器可以针对的最新版本 Roslyn 是什么?

    c - 当我 pthread_kill(runTheGame,SIGQUIT); 时,为什么我的 Visual Studio 说 "SIGQUIT"is not Defined?

    tfs - .tfignore 与 2017 相比不起作用

    c++ - 为什么 Visual Studio 编译器不使用我的 Mersenne-Twister 实现进行循环展开?

    c# - 发送电子邮件的代码

    visual-studio - 卸载使用 nuget.exe 安装的 nuget 软件包

    android - 让网络字体与 phonegap 和 android 一起工作 - 如何?

    jquery-mobile - 如何解决 jQuery Mobile 中页面之间转换缓慢的问题?

    android - Ionic 有没有办法直接在 Android 或 iOS 设备上进行调试?