简体   繁体   English

使用jQuery插件

[英]Using jQuery plugins

I am trying to use some of the jQuery plugins in my project (I am using RequireJS). 我正在尝试在我的项目中使用某些jQuery插件(我正在使用RequireJS)。 However I don't understand how to do it. 但是我不知道该怎么做。 I have tried to follow this: http://requirejs.org/docs/api.html#config-shim After what I understand it sets up a dependency of whats inside the array. 我尝试遵循以下步骤: http : //requirejs.org/docs/api.html#config-shim在我了解了之后,它建立了数组内部内容的依赖关系。 I thought I could do this in a module: 我以为可以在模块中做到这一点:

define(['ui'], function($) {

}

However it does not work. 但是,它不起作用。 What am I missing? 我想念什么? This is from my require.config: 这是从我的require.config中获取的:

shim: {
        'ui': {
            'deps': ['jquery']
        },
        'tools': {
            'deps': ['jquery', 'ui']
        }
}

and paths; 和路径;

'paths': {
    'jquery': 'lib/jquery/jquery',
    'ui': 'jquery/jquery-ui.min',
    'tools': 'jquery/jquery.tools.min',            
},
requirejs.config({
'paths': {
    'jquery': 'lib/jquery/jquery',
    'ui': 'jquery/jquery-ui.min',
    'tools': 'jquery/jquery.tools.min',            
},
    shim:{
        'ui': {
            'deps': ['jquery'],
            // exports :'ui'   As they are jquery plugins they will not require exports
        },
        'tools': {
            'deps': ['jquery', 'ui'],
             //exports : 'tools'
        }
} 
});

define(['jquery'], function($) {

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM