【问题标题】:IntelXDK Uncaught ReferenceError: LocalFileSystem is not definedIntelXDK Uncaught ReferenceError: LocalFileSystem 未定义
【发布时间】:2015-01-21 16:41:06
【问题描述】:

我尝试将本地生成的文件下载到设备文件系统。我正在使用一个仅适用于 chrome 的函数,所以我想用基于 Cordova 的函数替换它。我在 IntelXDK 中添加了:

-Cordova 插件 File 和 FileTransfer。

-Android 权限 WRITE_EXTERNAL-STORAGE 和 READ_EXTERNAL_STORAGE。

-下载功能:

function downloadCordova2(filename, text){
        //NEXT SAVE IT TO THE DEVICE'S LOCAL FILE SYSTEM
        console.log("file system...");
        window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {

            alert("in 1");
           console.log(fileSystem.name);
           console.log(fileSystem.root.name);
           console.log(fileSystem.root.fullPath);

           fileSystem.root.getFile("test.txt", {create: true}, function(entry) {
              var fileEntry = entry;
              console.log(entry);
             alert("in 2");
              entry.createWriter(function(writer) {
                 writer.onwrite = function(evt) {
                 console.log("write success");
              };

              console.log("writing to file");
                 writer.write( pdfOutput );
              }, function(error) {
                 console.log(error);
              });

           }, function(error){
              console.log(error);
           });
        },
        function(event){
         console.log( evt.target.error.code );
            alert(evt.target.error.message);
        });

    }

我在模拟器中、在为 chrome 构建后在 chrome 中、在使用真正的 Android 设备的模拟器中收到错误“Uncaught ReferenceError: LocalFileSystem is not defined”,当我安装 Android apk 时,我看不到它,但它也不行。

我错过了什么吗? 关于这个问题有类似的帖子,但是缺少插件,权限的问题......

【问题讨论】:

    标签: javascript android cordova intel-xdk


    【解决方案1】:

    将 HTML5 项目导入 IntelXDK 后,必须在 index.html 文件中添加 IntelXDK javascript 源的 script 标签:

    <script src="intelxdk.js"></script>
    

    该文件在项目源中不存在,但在构建项目时,IntelXDK 会自动将其复制到源的根目录中,在 index.html 旁边

    【讨论】:

      猜你喜欢
      • 2017-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-21
      • 1970-01-01
      • 2016-11-05
      相关资源
      最近更新 更多