试着熟悉一下require -但我不明白这个设置有什么问题--不能调用$(document).foundation(),因为$是未定义的。
requirejs.config({
baseUrl: '/js',
paths: {
jQuery: 'script.php?file=jquery.min.js',
foundation: 'script.php?file=foundation.min.js'
}
});
require(['jQuery'], function($) {
require(['foundation'], function() {
$(document).foundation(); // $ undefined?
});
// ... more code with different require sections
});发布于 2016-06-05 17:05:42
考虑将您的逻辑移到一个单独的文件中,例如app.js
然后,将require(['jQuery'], function($) { ...调用更改为类似于requirejs(['app'])的名称。
在app.js中,您应该定义一个模块,如下所示:
define(['jQuery', 'foundation'], function($, foundation) {
$(document).foundation();
});https://stackoverflow.com/questions/37639802
复制相似问题