2015-03-03 36 views
0

我正在使用dojo版本10加载按钮单击的外部视图。我尝试了包括dojo/Deferred在require中,仍然抛出相同的错误。什么可能是错误的?未捕获的异常:对象没有任何方法getInsatnce -DojoMobile

我得到的LogCat-

未捕获异常的错误:对象有在编译的代码没有method'getInstance”。

<script type="text/javascript" src="dojox/mobile/deviceTheme.js" 
 
     data-dojo-config="mblThemeFiles: ['base','Button']"></script> 
 
     <script type="text/javascript"> 
 
\t \t \t require([ 
 
\t \t \t "dojox/mobile/parser", 
 
\t \t \t  "dijit/registry", 
 
\t \t \t  "dojox/mobile/ViewController", 
 
\t \t \t "dojox/mobile/Heading", 
 
\t \t \t  "dojox/mobile", 
 
\t \t \t  "dojox/mobile/Button", 
 
\t \t \t  "dojox/mobile/View", 
 
\t \t \t  "dojo/Deferred" 
 
\t \t \t 
 
\t \t \t  
 
\t \t \t ], function(registry, ViewController){ 
 
\t \t \t  var vc = ViewController.getInstance(); 
 
\t \t \t  onBtn1Clicked = function(e){ 
 
\t \t \t   // the external view is loaded under the "container" view. 
 
\t \t \t   vc.openExternalView({ 
 
      url:"external.html", 
 
      transition:"slide" 
 
     }, registry.byId("container").containerNode); 
 
    }; 
 
}); 
 
    
 
    </script>
<div id="home" data-dojo-type="dojox/mobile/View"> 
 
    <h1 data-dojo-type="dojox/mobile/Heading">Home</h1> 
 
    <button data-dojo-type="dojox/mobile/Button" id="btn1" style="margin:5px;" 
 
      data-dojo-props='onClick:onBtn1Clicked'>Load external view</button> 
 
    </div> 
 
    <div id="container" data-dojo-type="dojox/mobile/View"> 
 
    <!-- An external view is loaded here when clicking the button above --> 
 
    </div> 
 

HI4g.png

+0

感谢没有必要的问题,使用投票和接受 – Anthon 2015-03-06 07:28:14

回答

0

你的论点在require()回调不匹配。 模块和回调参数之间应该有一对一映射。

 require([ 
      "dojox/mobile/parser", 
      "dijit/registry", 
      "dojox/mobile/ViewController", 
      "dojox/mobile/Heading", 
      "dojox/mobile", 
      "dojox/mobile/Button", 
      "dojox/mobile/View", 
      "dojo/Deferred" 

      /* Arguments should match the module. parser was missing as the first argument */ 
     ], function(parser, registry, ViewController){ 
       // rest of your code here. 

     }, registry.byId("container").containerNode); 
相关问题