[英]cordova open local file on windows 8.1 platform
我正在使用针对Windows 8.1平台的基于cordova的混合应用程序。 我正在使用Visual Studio 2013 Update 4 IDE进行调试和测试。 我正在尝试打开本地保存在设备“ C:\\ image.jpg”上的图像
我尝试了多个选项,例如:
使用window.open,并将文件协议用作window.open(“ file:/// C:/image.jpg”);
还尝试了fileopener2插件作为
cordova.plugins.fileOpener2.open('C://image.jpg','application / jpg',{错误:函数(e){console.log('错误状态:'+ e.status +'-错误消息:'+ e.message);},成功:function(){console.log('文件成功打开');
}});
但是它们都不起作用。
任何帮助都感激不尽。
谢谢,Chirag。
尽管没有很好的文档记录,cordova childBrowser不支持打开非HTML文件。 这是由于Microsoft提供的基础子浏览器实现。
让用户选择一个外部应用程序以打开此问题中所述的文件
var applicationData = Windows.Storage.ApplicationData.current;
var localFolder = applicationData.localFolder;
console.log(localFolder);
var imageFile = "image.png";
// Get the image file from the package's image directory
localFolder.getFileAsync(imageFile).then(
function (file) {
console.log("1");
// Set the show picker option
var options = new Windows.System.LauncherOptions();
options.displayApplicationPicker = true;
// Launch the retrieved file using the selected app
Windows.System.Launcher.launchFileAsync(file, options).then(
function (success) {
if (success) {
// File launched
console.log("2");
} else {
// File launch failed
console.log("3");
}
});
});
或查看Windows.Data.Pdf命名空间(如果您想尝试滚动自己的应用程序内解决方案)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.