0

我是 js 框架的新手,目前正在试用 Dojo,看看它是否最适合我们的项目。我正在努力使事情与 Dojo 一起工作。我尝试使用 Dojo 的 dgrid。代码或多或少是从教程中直接提升的,我相信我也有所有依赖项(如 dgrid/xstyle 和 put-selector)。但我仍然没有看到网格渲染页面。有人可以帮我解决这个问题吗?

这是我的 js 设置(在 tomcat 中)

在此处输入图像描述 这是我的代码(几乎直接从教程部分升起)

    <html>
<head>
    <meta charset="utf-8">
    <title>Tutorial: Hello dgrid!</title>
    <!-- this configuration assumes that the dgrid package is located
         on the filesystem as a sibling to the dojo package -->

<!-- load Dojo -->

<script>
    dojoConfig ={
    baseUrl: "js",
    isDebug: true, // enables debug
    async: true, // enables AMD loader
    packages: [
        {
        "name": "dojo",
        "location": "lib/dojo"
        },
        {
        "name": "dgrid",
        "location": "lib/dgrid"
        }   
    ]
    };
</script>
<script src="dojo/dojo.js"></script>
<script>
require(["dojo/parser", "dgrid/Grid", "dojo/domReady!"], function(Grid){
            alert("Hi");
            var data = [
                        { first: "Bob", last: "Barker", age: 89 },
                        { first: "Vanna", last: "White", age: 55 },
                        { first: "Pat", last: "Sajak", age: 65 }
                    ];
            var grid = new Grid(
                    { 
                         columns : {
                                first: "First Name",
                                last: "Last Name",
                                age: "Age"
                            }
                    }, "grid");
            grid.renderArray(data);            
        });
</script>

</head>
<body class="slate">
    <div id="grid" class="slate"></div>
    Hi grid
</body>
</html> 

这是我看到的(我根本看不到网格,也没有 js 错误)。 在此处输入图像描述

4

1 回答 1

0

in Grid there is "dojo/parser" because the first require isn't Grid. Try with

require(["dojo/parser", "dgrid/Grid", "dojo/domReady!"], function(parser,Grid){

or

  require([ "dgrid/Grid", "dojo/parser","dojo/domReady!"], function(Grid){
于 2013-07-18T12:28:13.400 回答