我正试着从请求js开始...下面是我正在尝试使用的最基本的示例……
我已经使用require js定义了"jquery“和" jqueryui”,并提供了jqueryui对jquery的依赖.....
根据文档..下面必须工作,我必须得到的jquit…但是警告框显示jqui是未定义的...
我的代码出了什么问题??
<script type="text/javascript" src="/Scripts/require.js"></script>
<script type="text/javascript">
// Configure the RequireJS paths to use an alias for the jQuery library.
requirejs.config({
paths: {
"jquery": "./Scripts/jquery-1.8.2",
"jqueryui": "./Scripts/jquery-ui-1.8.24"
},
shim: {
"jqueryui": ["jquery"]
}
});
// Now that we have configured a named alias for the jQuery library,
// let's try to load it using the named module.
requirejs(["jquery", "jqueryui"], function(jq, jqui) {
// Log the callback parameter.
console.log("jq.fn.jquery:", jq.fn.jquery);
alert(jqui);
});
</script>发布于 2013-05-18 02:52:45
这基本上是正确的。但是,您需要通过主jquery对象引用ui插件。没有单独的UI 'module‘。因此:
requirejs(["jquery", "jqueryui"], function(jq) { // Note! one parameter
// Log the callback parameter.
console.log("jq.fn.jquery:", jq.fn.jquery);
alert(jq.fn.button); // Note! The UI plugin is loaded!
});https://stackoverflow.com/questions/16607906
复制相似问题