vue.js - 每周vuejs日历不显示事件
问题描述
周历无法正确显示事件。甚至来自https://vuetifyjs.com/en/components/calendars的代码片段也会给我一个空日历。我想使用该功能,但找不到以下代码段出了什么问题。
我注意到模板 v-slot:dayHeadere 中有一个错字,并将其修复为 dayHeader。仍然,不起作用。 https://codepen.io/anon/pen/mgwjee?&editable=true&editors=111
<div id="app">
<v-app id="inspire">
<v-layout>
<v-flex>
<v-sheet height="400">
<!-- now is normally calculated by itself, but to keep the calendar in this date range to view events -->
<v-calendar
ref="calendar"
:now="today"
:value="today"
color="primary"
type="week"
>
<!-- the events at the top (all-day) -->
<template v-slot:dayHeader="{ date }">
<template v-for="event in eventsMap[date]">
<!-- all day events don't have time -->
<div
v-if="!event.time"
:key="event.title"
class="my-event"
@click="open(event)"
v-html="event.title"
></div>
</template>
</template>
<!-- the events at the bottom (timed) -->
<template v-slot:dayBody="{ date, timeToY, minutesToPixels }">
<template v-for="event in eventsMap[date]">
<!-- timed events -->
<div
v-if="event.time"
:key="event.title"
:style="{ top: timeToY(event.time) + 'px', height: minutesToPixels(event.duration) + 'px' }"
class="my-event with-time"
@click="open(event)"
v-html="event.title"
></div>
</template>
</template>
</v-calendar>
</v-sheet>
</v-flex>
</v-layout>
</v-app>
</div>
此代码段直接从 vuejs 网站保存。(当我保存它时,它至少不能正常工作)。
我希望事件能够正确显示。如果有人尝试使用此每周日历并成功,请告诉我您如何解决它。我将不胜感激!
解决方案
只需将v-slot替换为您的slot和slot-scope<template>
:
代替
<template v-slot:dayHeader="{ date }">
和
<template v-slot:dayBody="{ date, timeToY, minutesToPixels }">
经过
<template slot="dayHeader" slot-scope="{ date }">
和
<template slot="dayBody" slot-scope="{ date, timeToY, minutesToPixels }">
这是一个代码笔工作: https ://codepen.io/anon/pen/ErPZrK
推荐阅读
- c++ - 尝试使用 RapidXML 将唯一的 XML 属性附加到节点
- r - R - 从最旧的数据中减去最新的数据
- javascript - PHP没有将变量返回给ajax调用
- algolia - 有没有办法让 algolia 的独特设置忽略某个值?
- nginx - nginx 子域未重定向到所需端口
- .net - 控制台应用程序上的 .NET Core DI 记录器未登录到控制台
- ruby-on-rails - 保存 Ransack 搜索参数
- python - s3选择到熊猫数据框
- angular - ngFor 循环中的动态绑定 ngModel
- python - QTcpsocket/QTcpserver传输,如何使用QdataStream传输一个表数据