【发布时间】:2021-10-13 02:13:11
【问题描述】:
最近我尝试将 TUI(Toast UI)日历实现到我的 Blazor 项目之一中。不幸的是,按照指南和文档,我遇到了一些渲染问题。
填充的日历如下所示:
虽然它应该看起来像这样:
JS部分:
var Calendar = require('tui-calendar'); /* CommonJS */
require("tui-calendar/dist/tui-calendar.css");
// If you use the default popups, use this.
require("tui-date-picker/dist/tui-date-picker.css");
require("tui-time-picker/dist/tui-time-picker.css");
window.InitCalendar = function () {
var MONTHLY_CUSTOM_THEME = {
// month header 'dayname'
'month.dayname.height': '42px',
'month.dayname.borderLeft': 'none',
'month.dayname.paddingLeft': '8px',
'month.dayname.paddingRight': '0',
'month.dayname.fontSize': '13px',
'month.dayname.backgroundColor': 'inherit',
'month.dayname.fontWeight': 'normal',
'month.dayname.textAlign': 'left',
// month day grid cell 'day'
'month.holidayExceptThisMonth.color': '#f3acac',
'month.dayExceptThisMonth.color': '#bbb',
'month.weekend.backgroundColor': '#fafafa',
'month.day.fontSize': '16px',
// month schedule style
'month.schedule.borderRadius': '5px',
'month.schedule.height': '18px',
'month.schedule.marginTop': '2px',
'month.schedule.marginLeft': '10px',
'month.schedule.marginRight': '10px',
// month more view
'month.moreView.boxShadow': 'none',
'month.moreView.paddingBottom': '0',
'month.moreView.border': '1px solid #9a935a',
'month.moreView.backgroundColor': '#f9f3c6',
'month.moreViewTitle.height': '28px',
'month.moreViewTitle.marginBottom': '0',
'month.moreViewTitle.backgroundColor': '#f4f4f4',
'month.moreViewTitle.borderBottom': '1px solid #ddd',
'month.moreViewTitle.padding': '0 10px',
'month.moreViewList.padding': '10px'
};
var calendar = new Calendar('#calendar', {
defaultView: 'month', // monthly view option
theme: MONTHLY_CUSTOM_THEME
});
calendar.createSchedules([
{
id: 11035,
calendarId: "1",
category: "time",
title: "Vendor 1",
start: "2021-08-04",
end: "2021-08-19",
},
{
id: 11036,
calendarId: "2",
category: "time",
title: "Vendor 2",
start: "2021-08-09",
end: "2021-08-09",
},
{
id: 11039,
calendarId: "3",
category: "time",
title: "Vendor 3",
start: "2021-08-04",
end: "2021-08-04",
},
{
id: 11030,
calendarId: "4",
category: "time",
title: "Vendor 4",
start: "2021-08-13",
end: "2021-08-14",
},
]);
剃须刀:
@page "/personal/calendar"
@using System.Net.Http.Json
@inject IJSRuntime JsRuntime
<h1>Kalendarz</h1>
<div id="menu">
<span id="menu-navi">
<button type="button" class="btn btn-default btn-sm move-today" data-action="move-today">Today</button>
<button type="button" class="btn btn-default btn-sm move-day" data-action="move-prev">
<i class="calendar-icon ic-arrow-line-left" data-action="move-prev"></i>
</button>
<button type="button" class="btn btn-default btn-sm move-day" data-action="move-next">
<i class="calendar-icon ic-arrow-line-right" data-action="move-next"></i>
</button>
</span>
<span id="renderRange" class="render-range"></span>
</div>
<div id="calendar"></div>
@code{
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await JsRuntime.InvokeVoidAsync("InitCalendar");
}
}
}
作为 Blazor 的新手,我正在寻找一些见解,因为我无法验证问题:(
旁注 - 我已经尝试使用 gismofx/toast_ui.blazor_calendar,但我的实现和提供的演示都只有 404 和 NullReferenceExceptions。
【问题讨论】:
标签: javascript c# calendar blazor tui