我是window-8应用程序开发的新手。我想创建一个简单的javascript照片应用程序。在我的应用程序中,我希望显示一个assets文件夹,供用户选择他们选择的图像。有人能帮我一下吗?

发布于 2013-02-19 18:09:32
由于您正在使用JS构建您的应用程序,因此您需要做的就是编写一个小脚本,列出您放置在该文件夹中的资产的路径,并通过HTML页面将其链接起来。您是否正在尝试动态地执行此操作?我不认为存在这样的解决方案..
编辑:转念一想,您是否考虑过在每次向文件夹添加新资源时使用promise来运行脚本?保持对文件夹的检查,并在添加资源时提升标志,根据标志状态,调用承诺更新脚本将包含新添加的资源。您可能还需要考虑这样的情况:用户可能正在选择数据,而promise可能会更新页面。适当使用会话存储来处理这种情况。
发布于 2013-02-19 22:14:12
有一个FilePicker控件,可以让你轻松地显示图像/文件,供用户选择。这是a code sample;下载JavaScript版本。还有一些指导原则,其中包含指向API文档here的链接。
代码示例中的摘录:
// Create the picker object and set options
var openPicker = new Windows.Storage.Pickers.FileOpenPicker();
openPicker.viewMode = Windows.Storage.Pickers.PickerViewMode.thumbnail;
openPicker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.picturesLibrary;
// Users expect to have a filtered view of their folders depending on the scenario.
// For example, when choosing a documents folder, restrict the filetypes to documents for your application.
openPicker.fileTypeFilter.replaceAll([".png", ".jpg", ".jpeg"]);
// Open the picker for the user to pick a file
openPicker.pickSingleFileAsync().then(function (file) {
if (file) {
// Application now has read/write access to the picked file
WinJS.log && WinJS.log("Picked photo: " + file.name, "sample", "status");
} else {
// The picker was dismissed with no selected file
WinJS.log && WinJS.log("Operation cancelled.", "sample", "status");
}
}); https://stackoverflow.com/questions/14954597
复制相似问题