我正在与您分享发生冲突的js代码。它不包括控制台中的minicart/content.html
、authentication-popup.html
、Template/collection.html
、Template/messages.html
、checkout/captcha.html
等文件,而它在 luma(默认(主题中:
jQuery(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var calendar_mode = '';
var switchMode = '<?php echo $block->getScopeConfig('events/calendar_setting/allow_switch_mode'); ?>';
var defaultMode = '<?php echo $block->getScopeConfig('events/calendar_setting/default_view_mode'); ?>';
if (switchMode == '1') {
calendar_mode = 'month,agendaWeek,agendaDay';
}
var events = <?php echo $eventsJson; ?>;
jQuery('#calendar').fullCalendar({
<?php if ($locale != 'en') { ?>
locale: "<?php echo $locale; ?>",
<?php } ?>
editable: true,
displayEventEnd:true,
disableDragging: true,
header: {
left: 'prev,next today',
center: 'title',
right: calendar_mode
},
defaultView: defaultMode,
eventTextColor: 'white',
timeFormat: 'H:mm',
events: events,
eventMouseover: eventMouseoverFunc,
eventMouseout: eventMouseoutFunc
});
</script>
好的,
所以在调试时,我发现冲突是由于 2 个主要问题而发生的:
- 更改 jQuery('#calendar'(.fullCalendar({
- to jQuery('#any_unique_id'(.fullCalendar({ 的类,并并行地将日历div id 更改为相同的div id='calendar'> 更改为div id='any_unique _id'>
将 require 函数更改为 :
require(['jquery', 'mage/mage','fullcalendar', 'moment'<?php if ($locale != 'en') { ?>, 'locale_all'<?php } ?>], function($){
终于成功了!