GitHub 博客园 Nanakon

-_-#【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)
})

 

 

 

 

posted on 2014-02-23 22:24  jzm17173  阅读(334)  评论(0编辑  收藏  举报

导航

轻音