未捕获的异常:对象没有任何方法getInsatnce -DojoMobile

时间:2015-03-03 13:06:10

标签: dojo

我正在使用dojo版本10在按钮点击时加载外部视图。我尝试在require中包含dojo / Deferred,但它仍然会抛出同样的错误。什么可能是错的?

我在LogCat中遇到的错误 -

  

未捕获的异常:对象没有方法' getInstance'在编译的代码中。



<script type="text/javascript" src="dojox/mobile/deviceTheme.js"
        data-dojo-config="mblThemeFiles: ['base','Button']"></script>
        <script type="text/javascript">
			require([
			   "dojox/mobile/parser",
			    "dijit/registry",
			    "dojox/mobile/ViewController",
			 "dojox/mobile/Heading",
			    "dojox/mobile",
			    "dojox/mobile/Button",
			    "dojox/mobile/View",
			    "dojo/Deferred"
			  
			   
			], function(registry, ViewController){
			    var vc = ViewController.getInstance();
			    onBtn1Clicked = function(e){
			        // the external view is loaded under the "container" view.
			        vc.openExternalView({
            url:"external.html",
            transition:"slide"
        }, registry.byId("container").containerNode);
    };
});
  
   </script>
&#13;
  <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>
    
&#13;
&#13;
&#13;

HI4g.png

1 个答案:

答案 0 :(得分: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);