javascript - Windows 8 拆分应用程序自定义

标签 javascript html

据我们所知,Windows 8 拆分应用程序显示图 block ,因此我想显示图像,并且每个图 block 上的每个图像都应该不同。

这是我在default.html页面上所做的,其中标签是

<div class="item">
<img alt="some text" data-win-bind="source: imagePath">
<div class="item-overlay">
                <h4 class="item-title" data-win-bind="textContent: title"></h4>
                <h6 class="item-subtitle win-type-ellipsis" data-win-bind="textContent: subtitle"></h6>
            </div>
        </div>
    </div>

这是 data.js 文件的代码

var sampleGroups = [
            { key: "group1", title: "Group Title: 1", subtitle: "Group Subtitle: 1", **imagePath:"path of image file 1",** backgroundImage: darkGray, description: groupDescription },
            { key: "group2", title: "Group Title: 2", subtitle: "Group Subtitle: 2", **imagePath:"path of image file 2",** backgroundImage: lightGray, description: groupDescription },
            { key: "group3", title: "Group Title: 3", subtitle: "Group Subtitle: 3",**imagePath:"path of image file 3",** backgroundImage: mediumGray, description: groupDescription },
            { key: "group4", title: "Group Title: 4", subtitle: "Group Subtitle: 4",imagePath:"path of image file 4", backgroundImage: lightGray, description: groupDescription },
            { key: "group5", title: "Group Title: 5", subtitle: "Group Subtitle: 5", imagePath:"path of image file 5", backgroundImage: mediumGray, description: groupDescription },
            { key: "group6", title: "Group Title: 6", subtitle: "Group Subtitle: 6", **imagePath:"path of image file 6",** backgroundImage: darkGray, description: groupDescription }
        ];

最佳答案

这是解决方案(感谢 Usman ur Rehman 先生)

打开data.js并根据下面给出的代码更改代码

function generateSampleData() { var itemContent = "

Curabitur class aliquam vestibulum nam curae maecenas sed...";

    // These three strings encode placeholder images. You will want to set the
    // backgroundImage property in your real data to be URLs to images.
    var darkGray =  "images/1.png";
    var lightGray = "images/1.png";
    var mediumGray = "images/1.png";

    // Each of these sample groups must have a unique key to be displayed
    // separately.
    var sampleGroups = [
        { key: "group1", title: "Group Title: 1", subtitle: "Group Subtitle: 1", backgroundImage: darkGray, description: groupDescription },
        { key: "group2", title: "Group Title: 2", subtitle: "Group Subtitle: 2", backgroundImage: lightGray, description: groupDescription },
        { key: "group3", title: "Group Title: 3", subtitle: "Group Subtitle: 3", backgroundImage: mediumGray, description: groupDescription }, .....

关于javascript - Windows 8 拆分应用程序自定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13393056/

相关文章:

javascript - JQuery 仅选择所选元素内的元素

javascript - 如何使用 JS 从 MySQL 时间戳中获取月份

javascript - 函数一次接受回调作为输入并返回一个函数。

html - z-index 折叠菜单 bootstrap 4 CSS 无法正常工作

html - SCSS Transitions 上的文本重叠

javascript - 获取多个 div 之间的距离(水平距离,即左边界到右边界 - 以像素为单位)

c# - 用c#声明javascript变量

html - 将 div 放在 div 下

iphone - 显示只允许数字和小数点的输入?

javascript - jQuery wrapAll 带变量的两个元素