0

我正在dojo中尝试bordercontainer的基本示例,下面是它的html代码,但它没有显示所需的输出。谁能告诉我我在这里做错了什么。我仅从 dojo 教程中获取此示例代码,并且在 firebug 中也没有收到任何错误。

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>ICN Layout</title>

</head>
<body>
  <!-- load Dojo -->
  <script>dojoConfig = {parseOnLoad: true}</script>
  <script src="dojo/dojo.js">
  </script>
  <script>
   require([
   "dijit/layout/BorderContainer", "dijit/layout/ContentPane",
   "dojo/domReady!"
   ], function(BorderContainer, ContentPane){
   // create a BorderContainer as the top widget in the hierarchy
   var bc = new BorderContainer({
    style: "height: 300px; width: 500px;"
   });

   // create a ContentPane as the left pane in the BorderContainer
   var cp1 = new ContentPane({
    region: "left",
    style: "width: 100px",
    content: "hello world"
   });
   bc.addChild(cp1);

   // create a ContentPane as the center pane in the BorderContainer
   var cp2 = new ContentPane({
    region: "center",
    content: "how are you?"
   });
   bc.addChild(cp2);

   // put the top level widget into the document, and then call startup()
   bc.placeAt(document.body);
   bc.startup();
   });
  </script>
</body>
</html>
4

2 回答 2

1

我不知道您的 dojo/dojo.js 文件是否正确加载,但我没有在您的代码中看到所需的 dojo css 文件。确保包括那些(基于您使用的主题)。例如:

<link rel='stylesheet' href='http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/resources/dojo.css'>

<link rel='stylesheet' href='http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dijit/themes/claro/claro.css'>

以下是显示您的代码工作的两个工作示例:

笔:http ://codepen.io/kyledodge/pen/RPVjgY

小提琴:http: //jsfiddle.net/6v0x0jue/2/

于 2015-06-08T06:03:49.937 回答
0

您是否正确下载并放置了所有必需的 dojo dijit dojox 文件夹?然后,您可以在本地包含 css:

<link rel="stylesheet" href="dijit/themes/claro/claro.css" media="screen">
<link rel="stylesheet" href="dojo/resources/dojo.css">

如果您添加以下代码,我看到代码可以正常工作:

    // create a ContentPane as the Top pane in the BorderContainer
    var cp0 = new ContentPane({
        region: "top",
        content: "This is The Top!"
    });
    bc.addChild(cp0);

您可以看到 cp0 ContentPane 毫无问题地放置在顶部...我想您想查看边框(也许还有背景颜色)来可视化该区域?

于 2015-06-10T04:39:28.947 回答