这次给大家带来javascript模块加载器是怎么运行的,javascript模块加载器运行的注意事项有哪些,下面就是实战案例,一起来看一下。
定义
var MyModules = (function Manager() { var modules = {}; function define (name, deps, impl) { for(var j = 0, length = deps.length; j <p style="text-align: left;">使用</p><pre class="brush:php;toolbar:false">MyModules.define('test1', [], function() { function hello(name) { console.log(name); } return { hello: hello } }); MyModules.define('test2', ['test1'], function(test1) { function age(name, age) { console.log(test1.hello(name)); console.log(age); } return { age: age } }); MyModules.get('test2').age('mumu', '27');
相信看了本文案例你已经掌握了方法,更多精彩请关注php中文网其它相关文章!
推荐阅读:
以上就是javascript模块加载器是怎么运行的的详细内容,更多请关注php中文网其它相关文章!
Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号