首页 > 代码库 > requirejs2读书笔记
requirejs2读书笔记
If you want to do require() calls in the HTML page, then it is best to not use data-main. data-main is only intended for use when the page just has one main entry point, the data-main script. For pages that want to do inline require() calls, it is best to nest those inside a require() call for the configuration:
<script src="http://www.mamicode.com/scripts/require.js"></script><script>require([‘scripts/config‘], function() { // Configuration loaded now, safe to do other require calls // that depend on that config. require([‘foo‘], function(foo) { });});</script>
If the module does not have any dependencies, and it is just a collection of name/value pairs, then just pass an object literal to define():
If the module does not have any dependencies, and it is just a collection of name/value pairs, then just pass an object literal to define()://Inside file my/shirt.js: 如果没有定义模块名称,那所在的文件路径就是模块名define({ color: "black", size: "unisize"});
requirejs2读书笔记
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。