-_-#【RequireJS】Define a Module

define({
    color: 'black',
    size: 'unisize'
})
define(function() {
    // Do setup work here

    return {
        color: 'black',
        size: 'unisize'
    }
})
define(['jquery'], function($) {
    return {
        color: 'black',
        size: 'unisize',
        addToCart: function() {
            console.log($('.addToCart'))
        }
    }
})
define(['jquery'], function($) {
    return function(title) {
        return title
    }
})
define(function(require, exports, module) {
    var $ = require('jquery')

    console.log($)

    return function() {}
})
// Explicitly defines the "aaa" module
define('aaa', [], function() {
    var AAA = {
        color: 'black'
    }
    return AAA 
})
// 包装成了一个模块define({...})
require(['http://login.interface.baomihua.com/userapi.asmx/GetCurrentLoginUserInfo?jsoncallback=define&flag=json'], function(data) {
    console.log(data)
})
原文地址:https://www.cnblogs.com/jzm17173/p/3563730.html