我正在嘗試dojo中bordercontainer的基本示例,下面是它的html代碼,但它不顯示所需的輸出。任何人都可以告訴我我在這裏做錯了什麼。這個示例代碼我只從dojo教程中獲得,並且我在firebug中也沒有收到任何錯誤。邊界容器不能在dojo中工作
<!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>
dojo.js文件正在正確加載,但是關於dojo.css文件是否必須包含該文件?我們不能僅僅通過包含dojo.js來編寫代碼嗎? –
是的,你需要包含這些CSS文件才能正確渲染。這裏是沒有CSS的情況下的例子:http://jsfiddle.net/m2j72unh/1/注意到這個css文件在這個小提琴中被註釋掉了。 –
@GauravParek正如所提到的,你需要包含主題(claro.css)文件。您還需要爲body標籤添加'class =「claro」'屬性,即
'dojo小部件才能正確呈現 – frank