合理的做法,就是在requirejs之前作出合理的设置,如果本地已经预加载了模块就不进行加载,如果没有,就到我们本地加载:

// check for jQuery exist or not
if (!window.jQuery) {
    // load if it's not available or doesn't meet min standards
    var paths = {};
    paths.jquery = 'module/jquery/dist/jquery.min';
} else {
    // register the current jQuery
    define('jquery', [], function() { return window.jQuery; });
}
// 配置Requirejs
requirejs.config({
    baseUrl: '/resource',
    urlArgs: 'r=<%= version%>',
    paths: paths,
});

参考1

results matching ""

    No results matching ""