我已经遵循了互联网上提供的大多数指南,但是仍然无法帮助我解决问题。
我已经尝试过这个Cordova - Download a file in download folder
此https://www.npmjs.com/package/cordova-plugin-file-downloader
但是代码仍然无法正常工作。请帮助我...
function downloadURl(id) {
var storageLocation = "";
console.log(device.platform);
switch (device.platform) {
case "Android":
storageLocation = 'file:///android_asset/';
break;
case "iOS":
storageLocation = cordova.file.documentsDirectory;
break;
}
var fileUri = allDownloadNewsUrl[id];
function moveFile(fileUri) {
window.resolveLocalFileSystemURL(
fileUri,
function(fileEntry){
var parentEntry = storageLocation + "Download";
// move the file to a new directory and rename it
fileEntry.moveTo(parentEntry, allDownloadNewsTitle[id], success, fail);
},
errorCallback);
}
显示以下错误 未捕获的ReferenceError:未定义设备 在这两行代码中 console.log(device.platform); 切换(device.platform){