我正在尝试让fancybox在Magento 2.3(带有Infortis Ultimo主题)中工作。
但是我得到了:
1. Uncaught ReferenceError: jQuery is not defined
2. Uncaught TypeError: fancyboxExample.init is not a function
我正在尝试使用以下解决方案:
https://magento.stackexchange.com/questions/158894/jquery-fancybox-for-magento-2
错误
我使用default_head_blocks.xml
通过<link src="js/custom.js"/>
加载了以下内容。
require(['jquery', 'fancybox', 'domReady!'], function($, fancybox, doc) {
var fancyboxExample = {
openModal: function() {
$.fancybox.open(this.$modal);
},
closeModal: function() {
$.fancybox.close(true);
}
};
fancyboxExample.init();
});
谁能对此有所了解? 谢谢,
答案 0 :(得分:1)
您的必需JS配置应为
File: app/design/frontend/Store/theme/requirejs-config.js
var config = {
map: {
'*': {
fancybox: 'js/vendor/fancybox3/jquery.fancybox.min'
}
},
shim: {
'fancybox': {
deps: ['jquery']
}
}
};