我在:
包含一个新的js文件app/design/frontend/<Vendor>/<Theme>/web/js/flexslider.js
这给了我以下错误:
flexslider.js:1218 Uncaught ReferenceError: jQuery is not defined
at flexslider.js:1218
(anonymous) @ flexslider.js:1218
jquery-migrate.js:21 JQMIGRATE: Logging is active
(index):427 Uncaught TypeError: $(...).flexslider is not a function
at (index):427
at dispatch (jquery.js:5226)
at elemData.handle (jquery.js:4878)
我的requirejs-config中有这个:
var config = {
// When load 'requirejs' always load the following files also
deps: [
"/static/frontend/<Vendor>/<theme>/en_US/js/flexslider.js"
]
};
我做错了什么???
答案 0 :(得分:1)
问题是:你的js之后系统加载了jquery(你的js需要jquery才能工作)。
试试这个。
var config = {
map: {
'*': {
'flexslider': 'js/flexslider',
}
},
paths: {
'flexslider': 'js/flexslider',
},
shim: {
'flexslider': {
deps: ['jquery']
}
}
};