javascript - 在 dojo 中显示 Json 数据

标签 javascript html json dojo web

我正在构建 Dojo 移动应用程序。我有一个像这样的 Json 文件:

{
    "Introduction": [
        {
            "title": "Introduction",
            "toolbar": "Page 1",
            "cont, aabitant morbi tristique senectus et netus et malesuada fames ac turpis nt pellentesque vehicula. Nam ac diam lectus. Aliquam convallis posuere enim.",
        },
        {
            "title": "Introduction",
            "toolbar": "Page 2",
            "contesent vel nisi ipsum. Suspendisse potenti. Pellentesque ut ipsum sit amet eros posuere venenatvis egestas. Sed congue felis at risus congue m",
        }
    ],
    "services": [
        {
            "title": "services",
            "toolbar": "Page 1",
            "content": "Cras adipiscing sapien nec tortor vehicula sit amet vehicula est fring.
        }
    ],
}

首先我需要阅读这个文件。将涉及3页。 第一页将显示 2 个列表项“简介”和“服务”。单击“简介”列表项,将打开其第 1 页。 page1 中将有一个按钮。单击该按钮 page2 将打开。

“服务”也是如此。 我正在尝试使用 dojo.xhrGet({ItemFileReadStore 但徒劳无功。

最佳答案

您的 JSON 无效,您在两个“简介”对象中都缺少“内容”(参见 working example at jsFiddle):

{
    Introduction: 
    [
        {
            title:   "Introduction",
            toolbar: "Page 1",
            content: "cont, aabitant morbi tristique..."
        },
        {
            title:   "Introduction",
            toolbar: "Page 2",
            content: "contesent vel nisi ipsum..."
        }
    ],
    Services: 
    [
        {
            title:   "services",
            toolbar: "Page 1",
            content: "Cras adipiscing sapien nec..."
        }
    ]
};

关于javascript - 在 dojo 中显示 Json 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8494006/

相关文章:

html - 在换行时对齐图像图标后面的链接文本

html - 截断的文本在 Mozilla 中表现不同

javascript - Google 图表未在浏览器/JSON 中显示

json - 如何使 SoapUI json 请求与德国变音符号一起使用?

javascript - 为数组原型(prototype)添加了新方法

javascript - TypeError : func. apply 不是函数

javascript - 如何将变量从 jquery ajax 传递到 php mvc

javascript - Bootstrap 选项卡中的 CSS 阴影和圆 Angular

json - 服务器上的JSON.parse错误,但本地主机上没有

javascript - 使用javascript创建动态多维关联数组