Skip to content

Latest commit

ย 

History

History
32 lines (29 loc) ยท 708 Bytes

RequireJS.md

File metadata and controls

32 lines (29 loc) ยท 708 Bytes

https://github.com/requirejs/requirejs http://requirejs.cn/ http://www.ruanyifeng.com/blog/2012/11/require_js.html http://www.runoob.com/w3cnote/requirejs-tutorial-1.html

require.config({
ใ€€ใ€€ใ€€ใ€€shim: {

ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€'underscore':{
ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€exports: '_'
ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€},
ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€'backbone': {
ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€deps: ['underscore', 'jquery'],
ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€exports: 'Backbone'
ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€}
ใ€€ใ€€ใ€€ใ€€}
ใ€€ใ€€});

define()

ๆจกๅ—็š„ไพ่ต–
define(['myLib'], function(myLib){
ใ€€ใ€€ใ€€ใ€€function foo(){
ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€myLib.doSomething();
ใ€€ใ€€ใ€€ใ€€}
ใ€€ใ€€ใ€€ใ€€return {
ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€foo : foo
ใ€€ใ€€ใ€€ใ€€};
ใ€€ใ€€});