我已經嘗試過dojo 1.7.1,它的代碼是http://jsfiddle.net/nv4YC/dojo 1.7.0也可以。
From your link (the dojo tutorial) 它必須改變
dojo.require("dijit.Dialog");
,並在腳本標籤應該有異步:真
這樣data-dojo-config="async: true, parseOnLoad:true"
讓我的jsfiddle看到或嘗試這個代碼
<head>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dijit/themes/claro/claro.css">
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.7.1/dojo/dojo.js"
data-dojo-config="async: true, parseOnLoad:true"></script>
<script>
require(["dijit/registry", "dijit/Dialog"], function (registry)
{
// Show the dialog
showDialog = function showDialog()
{
registry.byId("terms").show();
}
// Hide the dialog
hideDialog = function hideDialog()
{
registry.byId("terms").hide();
}
});
</script>
</head>
<body class="claro">
<button onclick="showDialog();">View Terms and Conditions</button>
<div class="dijitHidden">
<div data-dojo-type="dijit.Dialog" style="width:600px;" data-dojo-props="title:'Terms and Conditions'"
id="terms">
<p>
<strong>Please agree to the following terms and conditions:</strong>
</p>
<div style="height:160px;overflow-y:scroll;border:1px solid #769dc4;padding:0 10px;width:600px">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sed suscipit
massa. Aenean vel turpis tincidunt velit gravida venenatis. In iaculis
urna non quam tincidunt elementum. Nunc pellentesque aliquam dui, ac facilisis
massa sollicitudin et. Donec tincidunt vulputate ultrices. Duis eu risus
ut ipsum auctor scelerisque non quis ante. Nam tempor lobortis justo, et
rhoncus mauris cursus et. Mauris auctor congue lectus auctor ultrices.
Aenean quis feugiat purus. Cras ornare vehicula tempus. Nunc placerat,
lorem adipiscing condimentum sagittis, augue velit ornare odio, eget semper
risus est et erat....</p>
</div>
<button onclick="hideDialog();">I Agree</button>
<button onclick="alert('You must agree!');">I Don't Agree</button>
</div>
</div>
</body>
好像API工具應該是撿了繼承的方法(和顯示他們當「在」按鈕,綠色的是上。聽起來像是另一個錯誤,可能與AMD轉換有關 – peller