RequireJS的问题

yaotomo 2018-01-31 10:35:54
昨天开始刚学RequireJS,遇到了一些问题不知道怎么解决
我要把5个js文件require进来,其中jqprint,tableExporter是jquery插件,依赖于jquery。formatdate.js是自定义的JS不依赖任何库
在require的回调函数中,打印这几个输出对象,结果bootstrap和formatdate是undifined,请教应该如何解决?


require.config({
baseUrl: '/themes/scripts/',
paths: {
jquery: 'jquery-1.8.2.min',
jqprint: 'jquery.jqprint-0.3',
bootstrap: 'bootstrap.min',
tableExporter: 'tableExporter.min',
formatDate: 'formatDate'
},
shim: {
bootstrap: {
deps: ['jquery'],
exports: 'bootstrap'
},
tableExporter: {
deps: ['jquery'],
exports: 'jQuery.fn.tableExport'
},
jqprint: {
deps: ['jquery'],
exports: 'jQuery.fn.jqprint'
},
formatDate:{
exports:'formatDate'
}
}
});

require(['jquery', 'bootstrap', 'tableExporter', 'jqprint', 'formatDate'],
function ($, bootstrap, tableExporter, jqprint, formatDate) {
console.log($);
console.log(bootstrap);
console.log(tableExporter);
console.log(jqprint);
console.log(formatDate);
})

...全文
530 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yaotomo 2018-04-25
  • 打赏
  • 举报
回复
谁来回复,结贴了
yaotomo 2018-04-25
  • 打赏
  • 举报
回复
引用 2 楼 u013116426 的回复:
有分吗?
当然有
___紫菜 2018-04-25
  • 打赏
  • 举报
回复
有分吗?

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧