`

How to use requirejs in client side

    博客分类:
  • js
 
阅读更多

How to use requirejs in client side

 

http://requirejs.org/ 

 

1.  in html

<script data-main="js/main" src="js/require.js"></script>

main.js is the entry point of our app logic


2.  in main.js

//config requirejs parameter
requirejs.config({
    baseUrl: 'js'   //this is the base folder, so we can use jquery not js/jquery
});


requirejs(['jquery', 'DataBinder','jquery.blockUI', 'bootstrap.min'],  // these are dependency will load async
    function ($, Model) {
    	//define inner function and var here

    	return {};  // return the object we want to export
    });


3.  define your own module, ex. DataBinder.js


define(["jquery"], function (jQuery) {
	
	//define inner function and var here

    return {};  // return the object we want to export
});

 

0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics