Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: 修改日历组件事件示例 #1405

Merged
merged 1 commit into from
Aug 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/calendar/_example/events.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,22 @@

<script>
export default {
data() {
return {
// 单元格单击和双击事件共存的时候,双击事件会触发单击事件(两次),这“可能不是”正确的效果,
// 这种场景下建议对单击事件进行延迟处理(详见下面 cellClick 和 cellDoubleClick 的代码)
cellClickTimmer: null,
};
},
methods: {
cellClick(options) {
console.log(`鼠标左键单击单元格 ${options.cell.formattedDate}`);
clearTimeout(this.cellClickTimmer); // 用于在双击事件中取消掉额外触发的一次单击事件
this.cellClickTimmer = setTimeout(() => {
console.log(`鼠标左键单击单元格 ${options.cell.formattedDate}`);
}, 300);
},
cellDoubleClick(options) {
clearTimeout(this.cellClickTimmer); // 用于在双击事件中取消掉额外触发另外一次单击事件
console.log(`鼠标双击单元格 ${options.cell.formattedDate}`);
},
cellRightClick(options) {
Expand Down