从Dojo 1.6.2到Dojo 1.13

时间:2018-03-12 16:15:02

标签: javascript php dojo

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

配置文件具有登录层,生成优化javascript为“login.js”。当浏览器呈现PHP登录页面时,它具有以下错误消息,如下所示。它似乎无法加载右侧的所有依赖项 如果我正在思考,请订购。你能帮我指出一下是什么 问题?我认为我的个人资料不是最新的。我试图设置不同的 配置文件中的选项,但它没有成功。

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

    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)

以下是我的申请资料。

    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页面

    <!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

3 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

javascript&#34; login.js&#34;是由...生成的optmized脚本 在与上面的配置文件一起编译时构建Dojo的脚本。我有 试图重新订购TextBox,但没有运气。我想这可能是 与Dojo配置文件的配置有关。 谢谢,

答案 2 :(得分:0)

我发现了这个问题。使用新的dojo语法,它使用了foward-slash data-dojo-type指定模块(&#34; dijit / form / TextBox&#34;)。我的代码还在 使用旧语法(&#34;&#39; dijit.form.TextBox&#34;)。在查看优化的登录脚本时,模块TextBox定义如下      &#39;的dijit /形式/文本框&#39;:函数(){ 这就是我收到错误消息的原因&#34;无法解析构造函数:&#39; dijit.form.TextBox&#39;&#34;