首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将dojo配置文件从Dojo 1.6.2迁移到Dojo 1.13

将dojo配置文件从Dojo 1.6.2迁移到Dojo 1.13
EN

Stack Overflow用户
提问于 2018-03-13 00:15:02
回答 3查看 182关注 0票数 1

这是我第一次在这里提问。我正在将一个dojo项目从版本1.6.2迁移到版本1.13。该应用程序使用Dojo在PHP上实现。我在使用当前应用程序配置文件时遇到问题。有一个登录页面,其中使用了一些dijit小部件,如TextBox、ComboBox等。

该配置文件具有登录层,该层将生成一个优化javascript,名为"login.js“。当浏览器呈现PHP登录页面时,它会显示以下错误消息,如下所示。如果我没记错的话,它似乎没能按照正确的顺序加载所有的依赖项。你能帮我指出问题出在哪里吗?我想我的个人资料不是最新的。我试着在配置文件中设置不同的选项,但没有成功。

我已经发布了我的应用程序配置文件和我的PHP登录页面,以及下面浏览器的错误消息,谢谢!

Loc

代码语言:javascript
复制
    dojo/parser::parse() error Error: Unable to resolve constructor for: 'dijit.form.TextBox'
    at Object.<anonymous> (login.js:formatted:87)
    at Object.map (dojo.js:51)
    at Object._instantiate (login.js:formatted:84)
    at login.js:formatted:375
    at f (dojo.js:116)
    at a.extend.then.then.a.then (dojo.js:118)
    at Object.parse (login.js:formatted:374)
    at dojo.js:47
    at l (dojo.js:52)
    at n (dojo.js:52)
(anonymous) @ login.js:formatted:379
11:39:39.343 dojo.js:28 TypeError: dijit.byId is not a function
    at showDialog ((index):38)
    at d (dojo.js:53)
    at l (dojo.js:52)
    at n (dojo.js:52)
    at p (dojo.js:54)
    at HTMLDocument.k (dojo.js:54)

以下是我的应用程序配置文件。

代码语言:javascript
复制
    dependencies = {

     optimize:"closure",
     layerOptimize: 'closure',


    layers: [
        {
            name: "login.js",
            dependencies: [
                "dojo/parser",
                "dojo/query",
                "dojo/_base.declare",
                "dojo/_base.fx",
                "dojo._base.lang",
                "dijit/form.Button",
                "dijit/form.TextBox",
                "dijit/form._TextBoxMixin",
                "dijit/form._FormValueWidget",
                "dijit/form.ValidationTextBox",
                "dijit/form.ComboBox"
            ]
        },


    prefixes: [
        [ "dijit", "../dijit" ],
        [ "dojox", "../dojox" ],
        [ "dojo", "../../dojo"]
    ]
}

以下是我的登录PHP页面

代码语言:javascript
复制
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
   <title> Application Console</title>

     <link rel="stylesheet" type="text/css" href="../../Dojo/dijit/themes/claro/claro.css"/>
        <script type="text/javascript">
          var dojoConfig = {
               has: {
                     "dojo-firebug": true
                    },
               parseOnLoad: true,
               isDebug: true,
               locale: 'en-us'
          };
     </script>

    <script type="text/javascript" src="../../Dojo/dojo/dojo.js"> </script>
    <?php
       $login_file='/var/www/xms/Dojo/dojo/login.js';
       /* Customized dojo JaveScript for UI optimization */
       if (file_exists($login_file)) {
          echo '<script type="text/javascript" src="../../Dojo/dojo/login.js"> </script>';
       } else {
       /* For backward compatibility */
           echo '<script>
            dojo.require("dojo.parser");
            dojo.require("dijit.form.Button");
            dojo.require("dijit.Dialog");
            dojo.require("dijit.form.TextBox");
            dojo.require("dijit.form.ComboBox");
           </script>';
       }
    ?>

    <script>
      dojo.addOnLoad(showDialog);


      function showDialog() {
          LoginLanding();
          dojo.connect( dijit.byId("passwordId"), "onKeyUp", checkForEnterKey );
      }

      function handleLoginVerifyReply(response, args)
      {       
          document.location.href= "index.php/consoleController";
      }

      function handleLoginVerifyErrorReply(response, args )
      {
           var responseText = response.responseText;
           var errObj = JSON.parse(responseText);
           dojo.byId("msgId").innerHTML = "<b>" + errObj.reason + "</b>";
      }

      function LoginLanding()
      {
          dojo.xhrPost({
                 url: "/index.php/verifyLogin/LoginLanding",
                 handleAs: "json",
                 timeout: 6000,
                 content: {} ,
                 load : function(response, args) {
                           if (response.status == 200)
                           {
                               handleLoginVerifyReply(response, args);
                           }
                           return response;
                        },
                 error: function(response,args) {
                           return response;
                        }
                 }
           );

      }

      function verifyLogin() {
        var vUsername= dijit.byId("userId").get("value");
        var vPassword= dijit.byId("passwordId").get("value");

        dojo.xhrPost({
                url: "/index.php/verifyLogin/login",
                handleAs: "text",
                timeout: 60000,
                content: { "usernameId" : vUsername, "passwordId" : vPassword } ,
                load : function(response, args) {
                          handleLoginVerifyReply(response, args);
                          return response;
                       },
                error: function(response,args) {
                          gUserNameLoggedIn="Unknown";
                          handleLoginVerifyErrorReply(response, args);
                          return response;
                       }
                }
        );

     }

      function cancelLogin() {
        console.log("calling cancelLogin");
      }

      function checkForEnterKey(ev)
      {
          if ( ev.keyCode == dojo.keys.ENTER ) {
              verifyLogin();
          }
      }

    </script>


    <style type="text/css">

        .loginPageIcon {
            position: absolute;
            left: 0px;
            top: 0px;
            height: 120px;
            width: 100%;
            background-color: #ffffff;
        }

        .loginPageTabContainer {
            display:flex;
            align-items:center;
            justify-content:center;
            position: absolute;  
            left: 0px; 
            top: 120px;
            margin-right: auto ;
            background-image: url('/images/slide-bg-3.jpg');
            height: 100px;
            width:  1920px; 
            font: normal 20px Open Sans !important;
            font-weight: bold;
            color: white;
            text-align:center;
        }

        h1.loginH1 {
            position: absolute;  
            margin-left: auto ;
            margin-right: auto ;
            margin-bottom: auto ;
            top: 10px ;
            color: black;
        }


        div.DivLogin {
            height: 250px;
            width: 400px;
            margin-left: auto ;
            margin-right: auto ;
            margin-top: 150px ;
            margin-bottom: auto ;
            -moz-border-radius: 4px;
            -webkit-border-radius: 4px;
            border-radius: 4px;
            -webkit-box-shadow: 0 2px 2px 0 #C2C2C2;
            box-shadow: 0 2px 2px 0 #C2C2C2;
            background-color:#679cc7
        }

        span.loginTitleTxt 
        {
            display: inline-block;
            width:100%;
            height: 100%;
            font: 500 15px Open Sans !important;
            font-weight: bold;
            text-align: center;
            margin: 0 auto;
            margin-top: 5px ;
        }


        hr.loginSeperator {
            position: relative;
            top: 10px;
            border-bottom: 1px dotted #cccccc;
            color: #ffffff;
            background-color: #ffffff;
            height: 1px;
            width: 95%;
        }


        .loginForm {
            position: relative;
            display: inline-block;
            left: 50%;
            top: 20px;
            margin-left: -180px;
            font: normal 14px Open Sans !important;
            width:50%; 
        }

        .loginTable {
            display: table;
        }

        .loginRow  {
            display: table-row;
        }

        .loginCellLeft {
            display: table-cell;
            height: 30px;
            padding-right: 40px;
        }

        .loginCellRight {
            display: table-cell;
            height: 30px;
            width:50px;
        }

                .loginCellEmpty {
                        display: table-cell;
                        height: 10px;
                }

        .loginMsgLabel {
            position: relative;
            left: 100%;
            margin-left: -200px;
            font: normal 14px Open Sans !important;
            color: #772222;
            width:100%; 
        }

        div.section.header {
            margin-left: -20px;
            margin-right: -10px;
            background-image:url("/images/slide-bg-3.jpg");
            background-position-y:-200px;
            padding:0!important;
            height: 210px;
            margin-top:6px
        }

        div.section.header .container {
            display:flex;
            align-items:center;
            justify-content:center;
            height:30%
        }

        div.section.header h1 {
            margin-top:280px;
            font: normal 40px Open Sans !important;
            font-weight: bold;
            color: white;
            max-width:90%
        }


    </style>


  </head>


  <body id="loginBodyId" class="claro"  bgcolor="white" style="font-size:medium;background-size:cover" >


     <div class="section header">
        <div class="container">
            <h1> Login Page </h1>
        </div>
     </div>


     <div class="DivLogin">

        <div>  <span class="loginTitleTxt"> Login </span>  </div>  
        <hr class="loginSeperator"></hr>

        <div class="loginForm">

            <div class="loginTable">
                <div class="loginRow">
                   <div class="loginCellLeft">
                       <label for="userId">Username:</label>
                   </div>
                   <div class="loginCellRight">
                       <input type="text" trim="true" dojoType="dijit.form.TextBox" value="" name="login" id="userId"  />
                   </div>
                </div>

                <div class="loginRow">
                   <div class="loginCellLeft">
                       <label for="passwordId">Password:</label>
                   </div>
                   <div class="loginCellRight">
                       <input type="password" trim="true" dojoType="dijit.form.TextBox" value="" name="password" id="passwordId"/>
                   </div>
                </div>

                <div class="loginRow">
                   <div class="loginCellLeft">
                        <label for="domainId">Domain:</label>
                   </div>

                   <div class="loginCellRight">
                        <select  id="domainId" autocomplete="true" dojoType="dijit.form.ComboBox"  value="Default">
                            <option selected="selected">default</option>
                        </select>
                   </div>
                </div>


                <div class="loginRow">
                   <div class="loginCellLeft">

                   </div>

                <div class="loginCellRight">
                        <button dojoType="dijit.form.Button" onClick="verifyLogin()">Login</button>                
                   </div>
                </div>
                                <div class="loginRow">
                                  <div class="loginCellEmpty">

                                   </div>
                                </div>

            </div>    <!-- End loginTable -->

            <label class="loginMsgLabel" id="msgId"></label>

        </div>  <!-- End loginForm -->

     </div>
</body>
</html>

谢谢

Loc

EN

回答 3

Stack Overflow用户

发布于 2018-03-13 04:09:25

通常,错误dojo/parser::parse() error Error: Unable to resolve constructor for: 'dijit.form.TextBox'表示依赖项存在问题。您是否可以检查您的login.js以确保正确引用了TexBox,并尝试将该导入语句向上移动,看看会发生什么情况?

票数 0
EN

Stack Overflow用户

发布于 2018-03-13 21:42:33

javascript "login.js“是优化后的脚本,它是由Dojo的构建脚本在与上面的概要文件一起编译时生成的。我试着重新订购TextBox,但没有运气。我认为这可能与Dojo配置文件的配置有关。谢谢,

Loc

票数 0
EN

Stack Overflow用户

发布于 2018-03-15 20:34:03

我发现了问题所在。在新的dojo语法中,它使用data-dojo-type中的前斜杠来指定模块("dijit/form/TextBox")。我的代码仍然使用旧的语法(“dijit.form.TextBox”)。在优化的登录脚本中,模块函数定义如下:‘dijit/form/ TextBox’:TextBox(){这就是为什么我收到错误消息"Unable to resolve constructor for:'dijit.form.TextBox'“的原因。

Loc

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49239843

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档