Dojo - “尝试使用id == centerPane注册窗口小部件,但是该ID已经被注册” [英] Dojo - "Tried to register widget with id==centerPane but that id is already registered"

查看:147
本文介绍了Dojo - “尝试使用id == centerPane注册窗口小部件,但是该ID已经被注册”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Dojo的内容窗格中遇到麻烦,在其中出现一秒钟,内容随后消失。我收到以下错误:

 未捕获ReferenceError:dijit未定义index.php:22 
dojo / parser :: parse()错误
错误
参数:undefined
获取堆栈:function(){[native code]}
message:试图使用id == centerPane注册窗口小部件但是该ID已经注册了
set stack:function(){[native code]}
type:undefined
__proto__:d
pre>

我已经回答了你可以销毁所有注册ID的答案,但是当我尝试它时,我仍然收到错误。

  var ids = [contentPane]; 
dijit.registry.forEach(function(w){
if(dojo.indexOf(ids,id)){
w.destroyRecursive();
}
});

  var ids = [contentPane]; 

dijit.registry.forEach(function(w){
if(dojo.indexOf(ids,1)){// 1将会你会被破坏
w .destroyRecursive();
}
});

如何解决这个错误?

解决方案

解决了,这是一个简单的事情,但我会坚持答案,以防其他人犯错误。
我的原始代码:

 < script> 
require([dojo / parser,dijit / layout / BorderContainer,dijit / layout / ContentPane],
函数(parser){
parser.parse();
});
< / script>

修正代码:

 <脚本> 
require([dojo / parser,dijit / layout / BorderContainer,dijit / layout / ContentPane]);
< / script>


I'm having trouble with a content pane in Dojo where it is appearing for a second with the content then disappearing. I am getting the following error:

 Uncaught ReferenceError: dijit is not defined index.php:22
    dojo/parser::parse() error 
    Error
    arguments: undefined
    get stack: function () { [native code] }
    message: "Tried to register widget with id==centerPane but that id is already registered"
    set stack: function () { [native code] }
    type: undefined
    __proto__: d

I have come accross answer where you can destroy all registered ID's but I am still getting the error when I try them.

var ids = ["contentPane"];
dijit.registry.forEach(function(w){ 
   if(dojo.indexOf(ids,id)){
        w.destroyRecursive();
   }
});

and

var ids = ["contentPane"];

dijit.registry.forEach(function(w){ 
   if(dojo.indexOf(ids,1)){ // 1 will be yourid it will get destroy
        w.destroyRecursive();
   }
});

How do I solve this error?

解决方案

Solved it, was something simple but I'll stick the answer up in case anyone else does my mistake. My original code:

    <script>
      require(["dojo/parser", "dijit/layout/BorderContainer", "dijit/layout/ContentPane"],
        function (parser) {
        parser.parse();
      });
</script>

Fixed code:

<script>
  require(["dojo/parser", "dijit/layout/BorderContainer", "dijit/layout/ContentPane"]);
</script>

这篇关于Dojo - “尝试使用id == centerPane注册窗口小部件,但是该ID已经被注册”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆