首页 > Web开发 > 详细

requirejs2读书笔记

时间:2016-09-18 23:40:59      阅读:226      评论:0      收藏:0      [点我收藏+]

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读书笔记

原文:http://www.cnblogs.com/linux-centos/p/5883388.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!