javascript - Uncaught ReferenceError : isApp is not defined

标签 javascript undefined referenceerror

我在控制台中收到“ Uncaught ReferenceError :isApp 未定义”, 我从一早上就试图找到这个错误的解决方案,但没有得到太多,我的 isApp.js 和 mApp.js 都保存在名为“js”的文件夹中,有人可以帮助我摆脱这个错误吗?这件事......提前致谢

//"......isApp.js file code starts from here..............."
var iA = function () {
    var t = this;
    this.user;
    var IsInvite = false;
    this.serverUrl = someLocalhostUrl;
     //some function - structure of functions is shown below
  
  //this.function1 = function(){
        //do something
  
  //};
  
  //lot of function

    this.initialize = function () {
        t.getUser();
        var pk = typeof t.user;
        if (!(typeof t.user === 'object')) {
            t.user = null;
            t.setUser();
        }
    }();
};

var isApp = new iA(); 
//"......isApp.js file code endss  here..............."




//"......mApp.js file code starts from here..............."
var mApp = function () {
    //var PostUrl = "http://localhost:52015/"
    var PostUrl = isApp.serverUrl + "/";
    var t = this;
    var u = {};
    this.ph, this.loc;
    var user, Email, UserName;
    var LoggedIn;

    this.initiate = function () {
        u = isApp.getUser();
        if (u && u.LoggedIn) {
            if (window.location.href.indexOf("index") == -1)
                $.mobile.changePage("index.html#p-start");
            //window.location = "index.html#p-home";
        }
    };

   //some function - structure of functions is shown below
  
  //this.function1 = function(){
        //do something
  
  //};
  
  //lot of function
  
    
    this.initiate();
};

m = new mApp();


//"......mApp.js file code ends here..............."
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <style>

    </style>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!--css starts here-->
    <link href="css/jquery.mobile-1.4.5.css" rel="stylesheet" />
    <link href="css/custom.css" rel="stylesheet" />
    <!--css ends here-->

    <!--js starts here-->
    <script src="js/jquery.js"></script>
    <script src="js/jquery.mobile-1.4.5.js"></script>
    <script src="js/jquery.signalR-2.2.0.min.js"></script>
    <script src="js/mApp.js"></script>
    <script src="js/isApp.js"></script>
    <script src="js/home.js"></script>
    <!--js ends here-->
    <!--<script>
        $(function () {
            $('.image').click(function () {
                alert("selection needed");
            });
            document.getElementById("startDate").valueAsDate = new Date();
        });
    </script>-->
</head>
<body>
    <div data-role="page" id="p-start">
        <div data-role="main" class="ui-content ui-responsive ui-body-a">
            <div class="align-center">
                <h3>Its our Rocking app</h3>
                <a href="#p-login">
                    <img src="images/temp-logo.jpg" class="logo" />
                </a>
                
            </div>
            
        </div>

    </div> 

   
</body>
</html>

最佳答案

您在 isApp.js 文件之前加载 mApp.js 文件,并且两个脚本都会立即执行,因此当 时,该函数自然尚未定义>mApp.js 被执行。

<script src="js/mApp.js"></script>
<script src="js/isApp.js"></script>

关于javascript - Uncaught ReferenceError : isApp is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32934963/

相关文章:

javascript - Google Chrome 上的 ReferenceError 但 Firefox 上没有(浏览器错误?)

javascript - require(processing-js) 抛出引用错误 : Navigator not Found

javascript - JavaScript 中的图像失真算法

c# - JavaScript 在本地工作,但在部署到网络服务器时无法工作

JavaScript:全局数组变量返回未定义

javascript - javascript(React Native)中出现未定义错误

javascript - 最后的行(尚未执行)如何影响代码的开头?为什么它会抛出不正确的错误?

javascript - 检查数字的数字是否重复 X 次的有效方法?

javascript - 使用 NodeJS 和 EJS 渲染 MySQL 查询

Javascript无法在 map 函数中捕获错误