问题
I'm trying to export an app done with Cordova to desktop/tablet Windows 8.1 and Windows Phone 8.1. My app works successfully on Android, iOS.
cordova -v
4.1.2
cordova plugins list
org.apache.cordova.file 1.3.1 "File"
But when I try on a Windows 8.1 or Windows Phone my app fails. The "cordova.file" is undefined. I can't access to cordova.file.dataDirectory to store my data or any cordova.file.* properties alias.
I see no "Quirks" for Windows on https://github.com/apache/cordova-plugin-file/blob/master/doc/index.md, did I miss something ?
UPDATE
Found a solution for Windows Phone, I set the 'cordova.file.dataDirectory' to '///' (device require org.apache.cordova.device) :
if(cordova.file === undefined){
// WP8
if(device.platform === "Win32NT"){
cordova.file = {
dataDirectory: '///'
}
}else
// Windows 8
if(device.platform === "windows"){
cordova.file = {
dataDirectory: '?????'
}
}
}
For Windows 8 I still seek for a solution..
回答1:
'ms-appdata:///local/' works for Windows 8 and WP 8.1
https://msdn.microsoft.com/en-us/library/windows/apps/jj655406.aspx has info on other available data paths
来源:https://stackoverflow.com/questions/26910891/cordova-file-is-undefined-for-windows-wp8