IntelXDK Uncaught ReferenceError: LocalFileSystem is not defined
IntelXDK Uncaught ReferenceError: LocalFileSystem is not defined
我尝试将本地生成的文件下载到设备文件系统。我正在使用仅适用于 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);
});
}
我在模拟器中收到错误 "Uncaught ReferenceError: LocalFileSystem is not defined",在为 chrome 构建后在 chrome 中,在使用真实 Android 设备的模拟器中,以及当我安装时Android apk,我看不到它,但它也不起作用。
我是否遗漏了任何内容?
关于这个问题有类似的帖子但是缺少插件,权限的问题...
将HTML5项目导入IntelXDK后,必须在index.html文件中添加IntelXDKjavascript源代码的脚本标签:
<script src="intelxdk.js"></script>
该文件在项目源中不存在,但在构建项目时,IntelXDK 会自动将其复制到源的根目录中,在 index.html
旁边
我尝试将本地生成的文件下载到设备文件系统。我正在使用仅适用于 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);
});
}
我在模拟器中收到错误 "Uncaught ReferenceError: LocalFileSystem is not defined",在为 chrome 构建后在 chrome 中,在使用真实 Android 设备的模拟器中,以及当我安装时Android apk,我看不到它,但它也不起作用。
我是否遗漏了任何内容? 关于这个问题有类似的帖子但是缺少插件,权限的问题...
将HTML5项目导入IntelXDK后,必须在index.html文件中添加IntelXDKjavascript源代码的脚本标签:
<script src="intelxdk.js"></script>
该文件在项目源中不存在,但在构建项目时,IntelXDK 会自动将其复制到源的根目录中,在 index.html
旁边