requirejs2读书笔记
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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="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读书笔记的主要内容,如果未能解决你的问题,请参考以下文章