《返回

reqiure.js加载非标准模块

模块定义
function fn1() {
  console.log("我是fn1()")
}

function fn2() {
  console.log("我是fn2()")
}
config.js配置
require.config({    
  shim: {
    "funs": {
      init: function() {
        return {
          fn1: fn1,
          fn2: fn2
        }
      }
    }
  }
});
模块调用
requirejs(["funs"], function(o) {
   o.fn1();
   o.fn2();
});