如何在使用RequireJS加载依赖项之前确保插件不会加载

时间:2015-07-28 03:52:34

标签: javascript jquery html requirejs

更新 我正在使用jquery.validationEngine.js。插入。除非先加载jquery.validate.min.js,否则我的插件jquery.validationEngine-en.js无法运行。

在我的HTML代码中,我会以这种方式加载脚本,它可以正常工作

<script type="text/javascript" src="/imagesrv/js/jquery.validationEngine-en.js"></script>
<script type="text/javascript" src="/imagesrv/marketing/js/jquery.validate.min.js"></script>

jquery.validationEngine-en.js包含在以下

define(['jqueryValidateEngine'],function($){
//plugin code here
});

和jquery.validate.min.js包含在

define(['jquery'],function($){
//plugin code here...
});

现在我使用required.js加载两个插件jquery.validate.min.js s依赖于jquery.validationEngine-en.j来加载。出于某种原因,我不断收到错误&#34; validationEngine不是一个函数&#34;这意味着插件没有正确加载。

require.config({
  baseUrl: "/imagesrv/marketing/requireJS/assets",
  paths: {
    // The libraries we use
    jquery: [
    '/imagesrv/marketing/js/jquery.min'
    ],
    bootstrap:     '/imagesrv/marketing/requireJS/assets/lib/bootstrap.wrapped.min',
    smartdevice: '/imagesrv/marketing/requireJS/assets/page/smart-device',
    main: '/imagesrv/marketing/requireJS/assets/page/main',
    jqueryValidateEn:     '/imagesrv/marketing/requireJS/assets/js/jquery.wrapped.validationEngine-en',
    jqueryValidateEngine:     '/imagesrv/marketing/requireJS/assets/js/jquery.wrapped.validationEngine'
  }

});


require(['main', 'bootstrap', 'jqueryValidateEn'], function($) {// Load up  this pages script, once the 'common' script has loaded
  console.log('jQuery and r.js have been loaded!');
});

0 个答案:

没有答案