Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/460.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将边框样式添加到完整日历中的事件_Javascript_Css_Fullcalendar_Fullcalendar 4 - Fatal编程技术网

Javascript 将边框样式添加到完整日历中的事件

Javascript 将边框样式添加到完整日历中的事件,javascript,css,fullcalendar,fullcalendar-4,Javascript,Css,Fullcalendar,Fullcalendar 4,我只想将边框样式添加到其中一个事件中,但不是完整日历中的所有事件。有什么帮助吗? 更改类似于希望将边框样式添加到完整日历的事件中。更改类似于希望将边框样式添加到完整日历的事件中 Only add the border style to the single event for the calendar. Only add the border style to the single event for the calendar. <script> document.addEve

我只想将边框样式添加到其中一个事件中,但不是完整日历中的所有事件。有什么帮助吗? 更改类似于希望将边框样式添加到完整日历的事件中。更改类似于希望将边框样式添加到完整日历的事件中

Only add the border style to the single event for the calendar.
 Only add the border style to the single event for the calendar.
<script>
  document.addEventListener('DOMContentLoaded', function() {
    var calendarEl = document.getElementById('calendar');

    var calendar = new FullCalendar.Calendar(calendarEl, {
      plugins: [ 'interaction', 'resourceDayGrid', 'resourceTimeGrid' ],
      defaultView: 'resourceTimeGridDay',
      defaultDate: '2019-08-07',
      editable: true,
      selectable: true,
      eventLimit: true, // allow "more" link when too many events
      header: {
        left: 'prev,next today',
        center: 'title',
        right: 
  'resourceTimeGridDay,resourceTimeGridTwoDay,timeGridWeek,dayGridMonth'
      },
      views: {
        resourceTimeGridTwoDay: {
          type: 'resourceTimeGrid',
          duration: { days: 2 },
          buttonText: '2 days',
        }
      },

      //// uncomment this line to hide the all-day slot
      //allDaySlot: false,

      resources: [
        { id: 'a', title: 'Room A', eventColor: 'pink' },
        { id: 'b', title: 'Room B', eventColor: 'green' },
        { id: 'c', title: 'Room C', eventColor: 'orange' },
        { id: 'd', title: 'Room D', eventColor: 'red' }
      ],
      events: [
        { id: '1', resourceId: 'a', start: '2019-08-06', end: '2019-08- 
     08', title: 'event 1' },
        { id: '2', resourceId: 'a', start: '2019-08-07T09:00:00', end: 
'2019-08-07T14:00:00', title: 'event 2' },
        { id: '3', resourceId: 'b', start: '2019-08-07T12:00:00', end: 
'2019-08-08T06:00:00', title: 'event 3' },
        { id: '4', resourceId: 'c', start: '2019-08-07T07:30:00', end: 
'2019-08-07T09:30:00', title: 'event 4' },
        { id: '5', resourceId: 'd', start: '2019-08-07T10:00:00', end: 
'2019-08-07T15:00:00', title: 'event 5' }
      ],

      select: function(arg) {
        console.log(
          'select',
          arg.startStr,
          arg.endStr,
          arg.resource ? arg.resource.id : '(no resource)'
        );
      },
      dateClick: function(arg) {
        console.log(
          'dateClick',
          arg.date,
          arg.resource ? arg.resource.id : '(no resource)'
        );
      }
    });

    calendar.render();
  });

</script>
<style>
    #a {
        border-color: 5px dashed yellow;
    }
  body {
    margin: 0;
    padding: 0;
    font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
    font-size: 14px;
  }

  #calendar {
    max-width: 900px;
    margin: 50px auto;
  }

</style>
</head>
<body>

  <div id='calendar'></div>

</body>
</html>
仅将边框样式添加到日历的单个事件中。
仅将边框样式添加到日历的单个事件中。
document.addEventListener('DOMContentLoaded',function(){
var calendarEl=document.getElementById('calendar');
var calendar=新的完整日历。日历(calendarEl{
插件:['interaction'、'resourceDayGrid'、'resourceTimeGrid'],
defaultView:'resourceTimeGridDay',
默认日期:“2019-08-07”,
是的,
是的,
eventLimit:true,//当事件太多时允许“更多”链接
标题:{
左:“上一个,下一个今天”,
中心:'标题',
正确的:
'resourceTimeGridDay,resourceTimeGridTwoDay,timeGridWeek,dayGridMonth'
},
观点:{
resourceTimeGridTwoDay:{
键入:“resourceTimeGrid”,
持续时间:{天:2},
按钮文字:“2天”,
}
},
////取消对此行的注释以隐藏全天时段
//全天时段:错,
资源:[
{id:'a',title:'Room a',eventColor:'pink'},
{id:'b',title:'Room b',eventColor:'green'},
{id:'c',title:'Room c',eventColor:'orange'},
{id:'d',title:'Room d',eventColor:'red'}
],
活动:[
{id:'1',resourceId:'a',开始:'2019-08-06',结束:'2019-08-
08',标题:'事件1'},
{id:'2',resourceId:'a',开始:'2019-08-07T09:00:00',结束:
“2019-08-07T14:00:00”,标题:“事件2”,
{id:'3',resourceId:'b',开始:'2019-08-07T12:00:00',结束:
“2019-08-08T06:00:00”,标题:“事件3”,
{id:'4',resourceId:'c',start:'2019-08-07T07:30:00',end:
“2019-08-07T09:30:00”,标题:“事件4”,
{id:'5',resourceId:'d',start:'2019-08-07T10:00:00',end:
“2019-08-07T15:00:00”,标题:“事件5”
],
选择:函数(arg){
console.log(
“选择”,
arg.startStr,
arg.endStr,
arg.resource?arg.resource.id:'(无资源)'
);
},
日期单击:函数(arg){
console.log(
“dateClick”,
arg.date,
arg.resource?arg.resource.id:'(无资源)'
);
}
});
calendar.render();
});
#a{
边框颜色:5px黄色虚线;
}
身体{
保证金:0;
填充:0;
字体系列:Arial、Helvetica Neue、Helvetica、无衬线字体;
字体大小:14px;
}
#历法{
最大宽度:900px;
保证金:50px自动;
}
仅将边框样式添加到日历的单个事件中。

您可以在事件中使用“borderColor”选项,如下所示:

Only add the border style to the single event for the calendar.
 Only add the border style to the single event for the calendar.
<script>
  document.addEventListener('DOMContentLoaded', function() {
    var calendarEl = document.getElementById('calendar');

    var calendar = new FullCalendar.Calendar(calendarEl, {
      plugins: [ 'interaction', 'resourceDayGrid', 'resourceTimeGrid' ],
      defaultView: 'resourceTimeGridDay',
      defaultDate: '2019-08-07',
      editable: true,
      selectable: true,
      eventLimit: true, // allow "more" link when too many events
      header: {
        left: 'prev,next today',
        center: 'title',
        right: 
  'resourceTimeGridDay,resourceTimeGridTwoDay,timeGridWeek,dayGridMonth'
      },
      views: {
        resourceTimeGridTwoDay: {
          type: 'resourceTimeGrid',
          duration: { days: 2 },
          buttonText: '2 days',
        }
      },

      //// uncomment this line to hide the all-day slot
      //allDaySlot: false,

      resources: [
        { id: 'a', title: 'Room A', eventColor: 'pink' },
        { id: 'b', title: 'Room B', eventColor: 'green' },
        { id: 'c', title: 'Room C', eventColor: 'orange' },
        { id: 'd', title: 'Room D', eventColor: 'red' }
      ],
      events: [
        { id: '1', resourceId: 'a', start: '2019-08-06', end: '2019-08- 
     08', title: 'event 1' },
        { id: '2', resourceId: 'a', start: '2019-08-07T09:00:00', end: 
'2019-08-07T14:00:00', title: 'event 2' },
        { id: '3', resourceId: 'b', start: '2019-08-07T12:00:00', end: 
'2019-08-08T06:00:00', title: 'event 3' },
        { id: '4', resourceId: 'c', start: '2019-08-07T07:30:00', end: 
'2019-08-07T09:30:00', title: 'event 4' },
        { id: '5', resourceId: 'd', start: '2019-08-07T10:00:00', end: 
'2019-08-07T15:00:00', title: 'event 5' }
      ],

      select: function(arg) {
        console.log(
          'select',
          arg.startStr,
          arg.endStr,
          arg.resource ? arg.resource.id : '(no resource)'
        );
      },
      dateClick: function(arg) {
        console.log(
          'dateClick',
          arg.date,
          arg.resource ? arg.resource.id : '(no resource)'
        );
      }
    });

    calendar.render();
  });

</script>
<style>
    #a {
        border-color: 5px dashed yellow;
    }
  body {
    margin: 0;
    padding: 0;
    font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
    font-size: 14px;
  }

  #calendar {
    max-width: 900px;
    margin: 50px auto;
  }

</style>
</head>
<body>

  <div id='calendar'></div>

</body>
</html>
events: [
        { id: '1', resourceId: 'a', start: '2019-08-06', end: '2019-08- 
     08', title: 'event 1', borderColor: '#0000ff' },
        { id: '2', resourceId: 'a', start: '2019-08-07T09:00:00', end: 
'2019-08-07T14:00:00', title: 'event 2' },
        { id: '3', resourceId: 'b', start: '2019-08-07T12:00:00', end: 
'2019-08-08T06:00:00', title: 'event 3' },
        { id: '4', resourceId: 'c', start: '2019-08-07T07:30:00', end: 
'2019-08-07T09:30:00', title: 'event 4' },
        { id: '5', resourceId: 'd', start: '2019-08-07T10:00:00', end: 
'2019-08-07T15:00:00', title: 'event 5' }
      ]
请注意,我在第一个事件中添加了“borderColor”选项

您可以使用eventRender应用边框样式,如下所示:

eventRender: function (info) {
  var eventId = info.event.id;
  if (eventId == '1')
    {
      $(info.el).css("border-style", "dashed");
      $(info.el).css("border-color", "#ffff00");
    }
}

你想具体改变哪一个,基于什么?另外,您使用的是哪个版本的fullCalendar?我正在添加多个事件,但希望更改一个具有边框样式(如虚线边框)的事件。您是否也可以共享完整的日历代码..那么,您是否有手动事件?或者您打算稍后动态加载事件?是否要将边框样式应用于备用事件?请确认将边框样式应用于特定事件的条件?手动加载事件,仅针对一个事件我要应用边框样式。您好,感谢您的回复,如果事件打算稍后动态加载事件,那么如何添加边框样式?有什么解决办法吗?同样的方法。。在动态方法中,您应该为事件分配一个id,并在eventRender中检查id是否与assign border相同。