我想知道为什么dojo没有响应元素的变化? 我举了一个简单的例子来说明我的问题!
<html >
<head>
<script>dojoConfig = {parseOnLoad: true}</script>
<script src='../dojo/dojo.js'></script>
<script>
require([
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane"
]);
require(["dojo/dom","dojo/on","dojo/domReady!"], function(dom, on){
on(dom.byId("tester"),"resize", function() { console.log('window on resize') });
});
</script>
</head>
<body>
<div data-dojo-type="dijit/layout/ContentPane" style="width: 50%;" >
<div data-dojo-type="dijit/layout/BorderContainer" id="tester">
</div>
</div>
</body>
</html>
当我使用on(window,"resize", function());
时,一切正常,但我不知道为什么上面的示例不起作用。
答案 0 :(得分:0)
试试这个(使用方面代替on):
<html >
<head>
<script>dojoConfig = {parseOnLoad: true}</script>
<script src='../dojo/dojo.js'></script>
<script>
require([
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane"
], function(BC, CP){
require(["dojo/aspect","dojo/domReady!"], function(aspect){
var bc= new BC({}, "tester");
bc.startup();
aspect.after(bc, "resize", function() { console.log('window on resize') });
});
});
</script>
</head>
<body>
<div id="tester" style="width: 50%;height:100%;">
</div>
</body>
</html>