zoukankan      html  css  js  c++  java
  • Requirejs加载超时问题的一个解决方法:设置waitSeconds=0

    有时Requirejs会遇到加载js超时问题

    除了排查js脚本问题,网络问题以外的一个解决方法是加大Require的等待时间waitSeconds,或者直接设置为0,这个参数的意义是:The number of seconds to wait before giving up on loading a script. Setting it to 0 disables the timeout. The default is 7 seconds.

    引用别的帖子:

    Load timeout for modules, Likely causes and fixes:

    There was a script error in one of the listed modules. If there is no script error in the browser's error console, and if you are using Firebug, try loading the page in another browser like Chrome or Safari. Sometimes script errors do not show up in Firebug.

    The path configuration for a module is incorrect. Check the "Net" or "Network" tab in the browser's developer tools to see if there was a 404 for an URL that would map to the module name. Make sure the script file is in the right place. In some cases you may need to use the paths configuration to fix the URL resolution for the script.

    The paths config was used to set two module IDs to the same file, and that file only has one anonymous module in it. If module IDs "something" and "lib/something" are both configured to point to the same "scripts/libs/something.js" file, and something.js only has one anonymous module in it, this kind of timeout error can occur. The fix is to make sure all module ID references use the same ID (either choose "something" or "lib/something" for all references), or use map config.

    解决方法:

      <script src="scripts/require.js"></script>
      <script>
      require.config({
        baseUrl: "/another/path",
        paths: {
          "some": "some/v1.0"
        },
        waitSeconds: 0
      });
      require( ["some/module", "my/module", "a.js", "b.js"],
        function(someModule,    myModule) {
          //This function will be called when all the dependencies
          //listed above are loaded. Note that this function could
          //be called before the page is loaded.
          //This callback is optional.
        }
      );
      </script> 

    相关链接:

    1.http://stackoverflow.com/questions/8582314/requirejs-and-text-plugin-load-timeout-for-modules
    2.http://stackoverflow.com/questions/20288007/load-timeout-for-modules-with-requirejs
    3.官网API文档:http://requirejs.org/docs/api.html#define
    4.中文API文档:http://requirejs.cn/docs/api.html#define
    5.中文API文档:http://makingmobile.org/docs/tools/requirejs-api-zh/#define
    6.中文文档:http://www.zfanw.com/blog/require-js.html
    7.中文文档:http://www.fanli7.net/a/bianchengyuyan/ASP/20130419/300243.html
    8.http://requirejs.org/docs/api.html#config-waitSeconds

  • 相关阅读:
    JAVA中获取当前系统时间
    struts2文件下载及 <param name="inputName">inputStream</param>的理解
    struts2文件下载,动态设置资源地址
    IE8上传文件时文件本地路径变成"C:fakepath"的问题
    Java设置session超时(失效)的三种方式
    学一点Git--20分钟git快速上手
    关于服务器响应,浏览器请求的理解以及javaWeb项目的编码问题
    GBK、GB2312、iso-8859-1之间的区别
    mysql的多表查询
    mysql错误:“ Every derived table must have its own alias”(每个派生出来的表都必须有一个自己的别名)
  • 原文地址:https://www.cnblogs.com/liuzhendong/p/4502741.html
Copyright © 2011-2022 走看看